Commit 9ae87bd3 authored by fkilic's avatar fkilic Committed by morgan
Browse files

Bug 1973265 - Put WebCodecs API behind RFP Target. r=tjr,webidl,smaug

parent f8f4dbce
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2844,7 +2844,7 @@ bool nsContentUtils::ShouldResistFingerprinting_dangerous(
  }

  // Web extension principals are also excluded
  if (BasePrincipal::Cast(aPrincipal)->AddonPolicy()) {
  if (NS_IsMainThread() && BasePrincipal::Cast(aPrincipal)->AddonPolicy()) {
    MOZ_LOG(nsContentUtils::ResistFingerprintingLog(), LogLevel::Debug,
            ("Inside ShouldResistFingerprinting(nsIPrincipal*)"
             " and AddonPolicy said false"));
+1 −1
Original line number Diff line number Diff line
@@ -1423,7 +1423,7 @@ JSObject* VideoFrame::WrapObject(JSContext* aCx,

/* static */
bool VideoFrame::PrefEnabled(JSContext* aCx, JSObject* aObj) {
  return StaticPrefs::dom_media_webcodecs_enabled() ||
  return nsRFPService::ExposeWebCodecsAPI(aCx, aObj) &&
         StaticPrefs::dom_media_webcodecs_image_decoder_enabled();
}

+9 −0
Original line number Diff line number Diff line
@@ -16,4 +16,13 @@ scheme = "https"
["test_imageDecoder_desiredSize.html"]
scheme = "https"

["test_rfp_api_disabling_disabled.html"]
scheme = "https"

["test_rfp_api_disabling_enabled.html"]
scheme = "https"

["test_rfp_api_disabling_exemption.html"]
scheme = "https"

["test_videoFrame_mismatched_codedSize.html"]
+67 −0
Original line number Diff line number Diff line
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script>
const apis = [
  "AudioData",
  "AudioDecoder",
  "AudioEncoder",
  "EncodedAudioChunk",
  "EncodedVideoChunk",
  "ImageDecoder",
  "ImageTrack",
  "ImageTrackList",
  "VideoColorSpace",
  "VideoDecoder",
  "VideoEncoder",
  "VideoFrame",
];

function enabledAPIs() {
  return apis.filter(api => typeof window[api] !== "undefined");
}

function enabledAPIsWorker() {
  const code = `
  onmessage = e => {
    const apis = ${JSON.stringify(apis)};
    postMessage(apis.filter(api => typeof self[api] !== "undefined"));
  };`;
  const blob = new Blob([code], { type: "application/javascript" });
  const worker = new Worker(URL.createObjectURL(blob));

  return new Promise((resolve) => {
    worker.addEventListener("message", async (e) => {
      worker.terminate();
      resolve(e.data);
    });

    worker.postMessage({});
  });
}

add_setup(async () => {
  await SpecialPowers.pushPrefEnv({
    set: [
      ["dom.media.webcodecs.enabled", true],
      ["dom.media.webcodecs.image-decoder.enabled", true]
    ],
  });
});

add_task(async () => {
  is(enabledAPIs().length, apis.length, true, "All WebCodecs APIs should be enabled");
  is(
    (await enabledAPIsWorker()).length,
    apis.length,
    "All WebCodecs APIs should be enabled in workers too"
  );
});
</script>
</body>
</html>
+69 −0
Original line number Diff line number Diff line
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script>
const apis = [
  "AudioData",
  "AudioDecoder",
  "AudioEncoder",
  "EncodedAudioChunk",
  "EncodedVideoChunk",
  "ImageDecoder",
  "ImageTrack",
  "ImageTrackList",
  "VideoColorSpace",
  "VideoDecoder",
  "VideoEncoder",
  "VideoFrame",
];

function enabledAPIs() {
  return apis.filter(api => typeof window[api] !== "undefined");
}

function enabledAPIsWorker() {
  const code = `
  onmessage = e => {
    const apis = ${JSON.stringify(apis)};
    postMessage(apis.filter(api => typeof self[api] !== "undefined"));
  };`;
  const blob = new Blob([code], { type: "application/javascript" });
  const worker = new Worker(URL.createObjectURL(blob));

  return new Promise((resolve) => {
    worker.addEventListener("message", async (e) => {
      worker.terminate();
      resolve(e.data);
    });

    worker.postMessage({});
  });
}

add_setup(async () => {
  await SpecialPowers.pushPrefEnv({
    set: [
      ["dom.media.webcodecs.enabled", true],
      ["dom.media.webcodecs.image-decoder.enabled", true],
      ["privacy.fingerprintingProtection", true],
      ["privacy.fingerprintingProtection.overrides", "-AllTargets,+WebCodecs"],
    ],
  });
});

add_task(async () => {
  is(enabledAPIs().length, 0, true, "All WebCodecs APIs should be disabled");
  is(
    (await enabledAPIsWorker()).length,
    0,
    "All WebCodecs APIs should be disabled in workers too"
  );
});
</script>
</body>
</html>
Loading