|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | +<title></title> |
| 5 | +<script src="/tests/SimpleTest/SimpleTest.js"></script> |
| 6 | +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
| 7 | +</head> |
| 8 | +<body> |
| 9 | +<script> |
| 10 | +const apis = [ |
| 11 | + "AudioData", |
| 12 | + "AudioDecoder", |
| 13 | + "AudioEncoder", |
| 14 | + "EncodedAudioChunk", |
| 15 | + "EncodedVideoChunk", |
| 16 | + "ImageDecoder", |
| 17 | + "ImageTrack", |
| 18 | + "ImageTrackList", |
| 19 | + "VideoColorSpace", |
| 20 | + "VideoDecoder", |
| 21 | + "VideoEncoder", |
| 22 | + "VideoFrame", |
| 23 | +]; |
| 24 | + |
| 25 | +function enabledAPIs() { |
| 26 | + return apis.filter(api => typeof window[api] !== "undefined"); |
| 27 | +} |
| 28 | + |
| 29 | +function enabledAPIsWorker() { |
| 30 | + const code = ` |
| 31 | + onmessage = e => { |
| 32 | + const apis = ${JSON.stringify(apis)}; |
| 33 | + postMessage(apis.filter(api => typeof self[api] !== "undefined")); |
| 34 | + };`; |
| 35 | + const blob = new Blob([code], { type: "application/javascript" }); |
| 36 | + const worker = new Worker(URL.createObjectURL(blob)); |
| 37 | + |
| 38 | + return new Promise((resolve) => { |
| 39 | + worker.addEventListener("message", async (e) => { |
| 40 | + worker.terminate(); |
| 41 | + resolve(e.data); |
| 42 | + }); |
| 43 | + |
| 44 | + worker.postMessage({}); |
| 45 | + }); |
| 46 | +} |
| 47 | + |
| 48 | +add_setup(async () => { |
| 49 | + await SpecialPowers.pushPrefEnv({ |
| 50 | + set: [ |
| 51 | + ["dom.media.webcodecs.enabled", true], |
| 52 | + ["dom.media.webcodecs.image-decoder.enabled", true], |
| 53 | + ["privacy.fingerprintingProtection", true], |
| 54 | + ["privacy.fingerprintingProtection.overrides", "-AllTargets,+WebCodecs"], |
| 55 | + ["privacy.resistFingerprinting.exemptedDomains", location.hostname] |
| 56 | + ], |
| 57 | + }); |
| 58 | +}); |
| 59 | + |
| 60 | +add_task(async () => { |
| 61 | + is(enabledAPIs().length, apis.length, true, "All WebCodecs APIs should be disabled"); |
| 62 | + is( |
| 63 | + (await enabledAPIsWorker()).length, |
| 64 | + apis.length, |
| 65 | + "All WebCodecs APIs should be disabled in workers too" |
| 66 | + ); |
| 67 | +}); |
| 68 | +</script> |
| 69 | +</body> |
| 70 | +</html> |
0 commit comments