summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/document-policy/experimental-features
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/document-policy/experimental-features
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/document-policy/experimental-features')
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/document-write.tentative.html91
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-tentative.html40
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-tentative.html.headers1
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-js-tentative.html36
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-js-tentative.html.headers1
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-keyframes-tentative.html23
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-keyframes-tentative.html.headers1
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/layout-animations-enabled-tentative.html30
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/resources/animation-property-height.js3
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/resources/async-script.js1
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/resources/common.js90
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/resources/defer-script.js1
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/resources/document-policy-image.html13
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/resources/document-write-allowed.html37
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/resources/document-write-disallowed.html37
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/resources/document-write-disallowed.html.headers1
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/resources/image.jpgbin0 -> 570855 bytes
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/resources/image.pngbin0 -> 217 bytes
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/resources/image.svg4
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/resources/parser-blocking-script.js1
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/resources/sync-script-test.js9
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/resources/video.ogvbin0 -> 103746 bytes
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/sync-script.tentative.https.sub.html22
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/sync-script.tentative.https.sub.html.headers1
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/unsized-media.tentative.https.sub.html95
-rw-r--r--testing/web-platform/tests/document-policy/experimental-features/unsized-media.tentative.https.sub.html.headers1
26 files changed, 539 insertions, 0 deletions
diff --git a/testing/web-platform/tests/document-policy/experimental-features/document-write.tentative.html b/testing/web-platform/tests/document-policy/experimental-features/document-write.tentative.html
new file mode 100644
index 0000000000..551703c6f5
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/document-write.tentative.html
@@ -0,0 +1,91 @@
+<!doctype html>
+<title>'document-write' tests</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/document-policy/experimental-features/resources/common.js"></script>
+<style>
+html, body {
+ height: 100%;
+ width: 100%;
+}
+</style>
+<body>
+<script>
+ "use strict";
+
+ function newIframe() {
+ var i = document.createElement("iframe");
+ document.body.appendChild(i);
+ return i;
+ }
+
+ let iframeElement = document.querySelector("iframe");
+ const allowed_url = url_base + "document-write-allowed.html";
+ const disallowed_url = url_base + "document-write-disallowed.html";
+
+ let text_to_write = "<div>FOO<\/div>";
+ let test_cases = [{
+ api: "open",
+ query: "body",
+ expected_value_enabled: false,
+ },
+ {
+ api: "close"
+ },
+ {
+ api: "write",
+ args: text_to_write,
+ query: "div",
+ expected_value_enabled: "FOO"
+ },
+ {
+ api: "writeln",
+ args: text_to_write,
+ query: "div",
+ expected_value_enabled: "FOO"
+ }];
+
+ // The feature 'document-write' is enabled by default and when it
+ // is enabled, all dynamic markup insertion API work as intended.
+ test_cases.forEach((tc) => {
+ promise_test(async() => {
+ let iframeElement = newIframe();
+ await loadUrlInIframe(iframeElement, allowed_url);
+ await sendMessageAndGetResponse(iframeElement.contentWindow, tc).then((response) => {
+ assert_false(
+ response.did_throw_exception,
+ `When feature is disabled, invoking 'document.${tc.api}' should not` +
+ " throw an exception.");
+ if (tc.query) {
+ assert_equals(
+ response.value,
+ tc.expected_value_enabled,
+ `The added script tag by 'document.${tc.api}' must have run.`);
+ }
+ });
+ }, `Verify 'document.${tc.api}' is not normally blocked.` );
+ });
+
+
+ // Disabling 'document-write' throws exception on the included API.
+ test_cases.forEach((tc) => {
+ promise_test(async() => {
+ let iframeElement = newIframe();
+ await loadUrlInIframe(iframeElement, disallowed_url);
+ await sendMessageAndGetResponse(iframeElement.contentWindow, tc).then((response) => {
+ assert_true(
+ response.did_throw_exception,
+ `When feature is enabled, invoking 'document.${tc.api}' should ` +
+ " throw an exception.");
+ if (tc.query) {
+ assert_not_equals(
+ response.value,
+ tc.expected_value_enabled,
+ `The added script tag by 'document.${tc.api}' must not have run.`);
+ }
+ });
+ }, `Verify 'document.${tc.api}' is blocked when the feature is disabled.` );
+ });
+
+</script>
+</body>
diff --git a/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-tentative.html b/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-tentative.html
new file mode 100644
index 0000000000..fd32ace78e
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-tentative.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<meta name="timeout" content="long">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/interpolation-testcommon.js"></script>
+<title> 'layout-animations' Policy : Correct behavior for affected and unaffected properties when
+ feature is disabled.
+</title>
+<body>
+<script>
+ // Sanity-check: Properties which are not affected by the policy 'layout-animations' should be
+ // interpolated normally (linearly) when the policy is disabled for the document.
+ test_interpolation(
+ {
+ property: "color",
+ from: "rgba(0, 50, 100, 1)",
+ to: "rgba(200, 150, 200, 1)",
+ test_prefix: 'Testing property "color".'
+ },
+ [
+ {at: 0.00, expect: "rgba(0, 50, 100, 1)"},
+ {at: 0.1, expect: "rgba(20, 60, 110, 1)"},
+ {at: 0.2, expect: "rgba(40, 70, 120, 1)"},
+ {at: 0.4, expect: "rgba(80, 90, 140, 1)"},
+ {at: 0.6, expect: "rgba(120, 110, 160, 1)"},
+ {at: 0.8, expect: "rgba(160, 130, 180, 1)"},
+ {at: 0.9, expect: "rgba(180, 140, 190, 1)"},
+ ]);
+
+ // There is no interpolation for the affected properties when the policy is disabled.
+ ["bottom", "height", "left", "right", "top", "width"].forEach(
+ (p) => test_no_interpolation(
+ {
+ property: p,
+ from: "100px",
+ to: "200px",
+ test_prefix: `Testing property "${p}".`
+ }));
+</script>
+</body>
diff --git a/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-tentative.html.headers b/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-tentative.html.headers
new file mode 100644
index 0000000000..745da550ee
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-tentative.html.headers
@@ -0,0 +1 @@
+Document-Policy: layout-animations=?0
diff --git a/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-js-tentative.html b/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-js-tentative.html
new file mode 100644
index 0000000000..ee7c295156
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-js-tentative.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/document-policy/experimental-features/resources/common.js"></script>
+<title> 'layout-animations' Policy : violation reports from javascript
+</title>
+<body>
+<script>
+ promise_test(async () => {
+ let promise = wait_for_violation_in_file(
+ "layout-animations",
+ "animation-property-height.js");
+ let script = document.createElement("script");
+ script.src = "/document-policy/experimental-features/resources/" +
+ "animation-property-height.js";
+ document.body.appendChild(script);
+ await promise;
+ },
+ "Verify that when 'layout-animations' is disabled, an 'element.animate' " +
+ "API including a keyframe that uses a blocked property generates violation " +
+ "report (linked scripts).");
+
+ promise_test(async () => {
+ let promise = wait_for_violation_in_file(
+ "layout-animations",
+ "layout-animations-disabled-violation-report-js-tentative.html");
+ let div = document.createElement("div");
+ document.body.appendChild(div);
+ div.animate([{width: "100px"}, {width: "200px"}]);
+ await promise;
+ },
+ "Verify that when 'layout-animations' is disabled, an 'element.animate' " +
+ "API including a keyframe that uses a blocked property generates violation " +
+ "report (inline scripts).");
+</script>
+</body>
diff --git a/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-js-tentative.html.headers b/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-js-tentative.html.headers
new file mode 100644
index 0000000000..745da550ee
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-js-tentative.html.headers
@@ -0,0 +1 @@
+Document-Policy: layout-animations=?0
diff --git a/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-keyframes-tentative.html b/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-keyframes-tentative.html
new file mode 100644
index 0000000000..cd9210cc13
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-keyframes-tentative.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/document-policy/experimental-features/resources/common.js"></script>
+<title> 'layout-animations' Policy : violation reports from CSS keyframes
+</title>
+<body>
+<script>
+ promise_test(async () => {
+ let promise = wait_for_violation_in_file(
+ "layout-animations", null /* source not specified */);
+ let style = document.createElement("style");
+ style.innerHTML = `@keyframes animation_property_top {
+ from { top: 0px }
+ to { top: 100px }
+ }`;
+ document.body.appendChild(style);
+ await promise;
+ },
+ "Verify that when 'layout-animations' is disabled, a keyframes which " +
+ "includes a blocked property generates violation report.");
+</script>
+</body>
diff --git a/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-keyframes-tentative.html.headers b/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-keyframes-tentative.html.headers
new file mode 100644
index 0000000000..745da550ee
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/layout-animations-disabled-violation-report-keyframes-tentative.html.headers
@@ -0,0 +1 @@
+Document-Policy: layout-animations=?0
diff --git a/testing/web-platform/tests/document-policy/experimental-features/layout-animations-enabled-tentative.html b/testing/web-platform/tests/document-policy/experimental-features/layout-animations-enabled-tentative.html
new file mode 100644
index 0000000000..19e405496e
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/layout-animations-enabled-tentative.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/interpolation-testcommon.js"></script>
+<title> 'layout-animations' Policy : Correct behavior for affected and unaffected properties when
+ feature is enabled.
+</title>
+<body>
+<script>
+ // The expectation for all the following properties could be the same (they are all of type length).
+ let length_expectations_100_to_200 = [
+ {at: 0.00, expect: "100px"},
+ {at: 0.1, expect: "110px"},
+ {at: 0.2, expect: "120px"},
+ {at: 0.4, expect: "140px"},
+ {at: 0.6, expect: "160px"},
+ {at: 0.8, expect: "180px"},
+ {at: 0.9, expect: "190px"},
+ ];
+ // Ensure all the affected animations run normally.
+ ["bottom", "height", "left", "right", "top", "width"].forEach(
+ (p) => test_interpolation({
+ property: p,
+ from: "100px",
+ to: "200px",
+ test_prefix: `Testing property "${p}".`
+ },
+ length_expectations_100_to_200));
+</script>
+</body>
diff --git a/testing/web-platform/tests/document-policy/experimental-features/resources/animation-property-height.js b/testing/web-platform/tests/document-policy/experimental-features/resources/animation-property-height.js
new file mode 100644
index 0000000000..79316cb488
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/resources/animation-property-height.js
@@ -0,0 +1,3 @@
+let div = document.createElement("div");
+document.body.appendChild(div);
+div.animate([{"height": "0px"}, {"height": "100px"}]);
diff --git a/testing/web-platform/tests/document-policy/experimental-features/resources/async-script.js b/testing/web-platform/tests/document-policy/experimental-features/resources/async-script.js
new file mode 100644
index 0000000000..3c0ee6d023
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/resources/async-script.js
@@ -0,0 +1 @@
+window.didExecuteExternalAsyncScript = true;
diff --git a/testing/web-platform/tests/document-policy/experimental-features/resources/common.js b/testing/web-platform/tests/document-policy/experimental-features/resources/common.js
new file mode 100644
index 0000000000..639847abf3
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/resources/common.js
@@ -0,0 +1,90 @@
+const url_base = "/document-policy/experimental-features/resources/";
+window.messageResponseCallback = null;
+
+// Returns a promise which is resolved when the <iframe> is navigated to |url|
+// and "load" handler has been called.
+function loadUrlInIframe(iframe, url) {
+ return new Promise((resolve) => {
+ iframe.addEventListener("load", resolve);
+ iframe.src = url;
+ });
+}
+
+// Posts |message| to |target| and resolves the promise with the response coming
+// back from |target|.
+function sendMessageAndGetResponse(target, message) {
+ return new Promise((resolve) => {
+ window.messageResponseCallback = resolve;
+ target.postMessage(message, "*");
+ });
+}
+
+
+function onMessage(e) {
+ if (window.messageResponseCallback) {
+ window.messageResponseCallback(e.data);
+ window.messageResponseCallback = null;
+ }
+}
+
+window.addEventListener("message", onMessage);
+
+// Waits for |load_timeout| before resolving the promise. It will resolve the
+// promise sooner if a message event with |e.data.id| of |id| is received.
+// In such a case the response is the contents of the message |e.data.contents|.
+// Otherwise, returns false (when timeout occurs).
+function waitForMessageOrTimeout(t, id, load_timeout) {
+ return new Promise((resolve) => {
+ window.addEventListener(
+ "message",
+ (e) => {
+ if (!e.data || e.data.id !== id)
+ return;
+ resolve(e.data.contents);
+ }
+ );
+ t.step_timeout(() => { resolve(false); }, load_timeout);
+ });
+}
+
+function createIframe(container, attributes) {
+ var new_iframe = document.createElement("iframe");
+ for (attr_name in attributes)
+ new_iframe.setAttribute(attr_name, attributes[attr_name]);
+ container.appendChild(new_iframe);
+ return new_iframe;
+}
+
+// Returns a promise which is resolved when |load| event is dispatched for |e|.
+function wait_for_load(e) {
+ return new Promise((resolve) => {
+ e.addEventListener("load", resolve);
+ });
+}
+
+setup(() => {
+ window.reporting_observer_instance = new ReportingObserver((reports, observer) => {
+ if (window.reporting_observer_callback) {
+ reports.forEach(window.reporting_observer_callback);
+ }
+ }, {types: ["document-policy-violation"]});
+ window.reporting_observer_instance.observe();
+ window.reporting_observer_callback = null;
+});
+
+// Waits for a violation in |feature| and source file containing |file_name|.
+function wait_for_violation_in_file(feature, file_name) {
+ return new Promise( (resolve) => {
+ assert_equals(null, window.reporting_observer_callback);
+ window.reporting_observer_callback = (report) => {
+ var feature_match = (feature === report.body.featureId);
+ var file_name_match =
+ !file_name ||
+ (report.body.sourceFile.indexOf(file_name) !== -1);
+ if (feature_match && file_name_match) {
+ window.reporting_observer_callback = null;
+ resolve(report);
+ }
+ };
+ });
+}
diff --git a/testing/web-platform/tests/document-policy/experimental-features/resources/defer-script.js b/testing/web-platform/tests/document-policy/experimental-features/resources/defer-script.js
new file mode 100644
index 0000000000..8d248ee0d0
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/resources/defer-script.js
@@ -0,0 +1 @@
+window.didExecuteExternalDeferredScript = true;
diff --git a/testing/web-platform/tests/document-policy/experimental-features/resources/document-policy-image.html b/testing/web-platform/tests/document-policy/experimental-features/resources/document-policy-image.html
new file mode 100644
index 0000000000..4e5b919bd1
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/resources/document-policy-image.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<body>
+<script>
+window.addEventListener('load', function() {
+ var img = document.createElement('IMG');
+ img.setAttribute("src", "/document-policy/experimental-features/resources/image.jpg");
+ img.addEventListener('load', function() {
+ parent.postMessage({width: img.width, height: img.height}, '*');
+ });
+ document.body.appendChild(img);
+});
+</script>
+</body>
diff --git a/testing/web-platform/tests/document-policy/experimental-features/resources/document-write-allowed.html b/testing/web-platform/tests/document-policy/experimental-features/resources/document-write-allowed.html
new file mode 100644
index 0000000000..633fa85e6a
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/resources/document-write-allowed.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<style>
+#spacer {
+ width: 200%;
+ height: 200%;
+}
+</style>
+<body>
+<script>
+ window.addEventListener("message", onMessageReceived);
+
+ function test(api, args) {
+ let did_throw = false;
+ try {
+ document[api](args);
+ } catch(e) {
+ did_throw = true;
+ }
+ return did_throw;
+ }
+
+ function onMessageReceived(e) {
+ let msg = e.data;
+
+ msg.did_throw_exception = test(msg.api, msg.args);
+ if (msg.query) {
+ let el = document.querySelector(msg.query);
+ msg.value = el ? el.innerHTML : false;
+ }
+ ackMessage(msg, e.source);
+ }
+
+ function ackMessage(msg, source) {
+ source.postMessage(msg, "*");
+ }
+</script>
+</body>
diff --git a/testing/web-platform/tests/document-policy/experimental-features/resources/document-write-disallowed.html b/testing/web-platform/tests/document-policy/experimental-features/resources/document-write-disallowed.html
new file mode 100644
index 0000000000..633fa85e6a
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/resources/document-write-disallowed.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<style>
+#spacer {
+ width: 200%;
+ height: 200%;
+}
+</style>
+<body>
+<script>
+ window.addEventListener("message", onMessageReceived);
+
+ function test(api, args) {
+ let did_throw = false;
+ try {
+ document[api](args);
+ } catch(e) {
+ did_throw = true;
+ }
+ return did_throw;
+ }
+
+ function onMessageReceived(e) {
+ let msg = e.data;
+
+ msg.did_throw_exception = test(msg.api, msg.args);
+ if (msg.query) {
+ let el = document.querySelector(msg.query);
+ msg.value = el ? el.innerHTML : false;
+ }
+ ackMessage(msg, e.source);
+ }
+
+ function ackMessage(msg, source) {
+ source.postMessage(msg, "*");
+ }
+</script>
+</body>
diff --git a/testing/web-platform/tests/document-policy/experimental-features/resources/document-write-disallowed.html.headers b/testing/web-platform/tests/document-policy/experimental-features/resources/document-write-disallowed.html.headers
new file mode 100644
index 0000000000..32846f724a
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/resources/document-write-disallowed.html.headers
@@ -0,0 +1 @@
+Document-Policy: document-write=?0 \ No newline at end of file
diff --git a/testing/web-platform/tests/document-policy/experimental-features/resources/image.jpg b/testing/web-platform/tests/document-policy/experimental-features/resources/image.jpg
new file mode 100644
index 0000000000..430f5c514a
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/resources/image.jpg
Binary files differ
diff --git a/testing/web-platform/tests/document-policy/experimental-features/resources/image.png b/testing/web-platform/tests/document-policy/experimental-features/resources/image.png
new file mode 100644
index 0000000000..556fa72704
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/resources/image.png
Binary files differ
diff --git a/testing/web-platform/tests/document-policy/experimental-features/resources/image.svg b/testing/web-platform/tests/document-policy/experimental-features/resources/image.svg
new file mode 100644
index 0000000000..73ca820915
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/resources/image.svg
@@ -0,0 +1,4 @@
+<?xml version="1.0" standalone="yes"?>
+
+<svg version="1.1" viewBox="0.0 0.0 960.0 720.0" fill="none" stroke="none" stroke-linecap="square" stroke-miterlimit="10" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M267.88715 112.77165L267.88715 112.77165C267.88715 93.211205 283.74402 77.35433 303.30447 77.35433L303.30447 77.35433C312.69772 77.35433 321.70627 81.085785 328.3483 87.72782C334.99033 94.36986 338.72177 103.378395 338.72177 112.77165L338.72177 112.77165C338.72177 132.3321 322.8649 148.18898 303.30447 148.18898L303.30447 148.18898C283.74402 148.18898 267.88715 132.3321 267.88715 112.77165Z" fill-rule="nonzero" fill="#cfe2f3" stroke="#073763" stroke-width="2.0" stroke-linejoin="round" stroke-linecap="butt"></path><path d="M294.15125 114.47782L295.1825 114.61845Q295.01062 115.68095 294.3075 116.29032Q293.60437 116.8997 292.58875 116.8997Q291.3075 116.8997 290.53406 116.06376Q289.76062 115.22782 289.76062 113.66532Q289.76062 112.66532 290.09656 111.90751Q290.4325 111.1497 291.11218 110.7747Q291.79187 110.3997 292.60437 110.3997Q293.60437 110.3997 294.2528 110.90751Q294.90125 111.41532 295.08875 112.36845L294.0575 112.5247Q293.91687 111.8997 293.54187 111.579384Q293.16687 111.25907 292.63562 111.25907Q291.83875 111.25907 291.33875 111.829384Q290.83875 112.3997 290.83875 113.63407Q290.83875 114.8997 291.32312 115.4622Q291.8075 116.0247 292.57312 116.0247Q293.19812 116.0247 293.61218 115.6497Q294.02625 115.2747 294.15125 114.47782ZM296.08875 109.38407L296.08875 108.16532L297.15125 108.16532L297.15125 109.38407L296.08875 109.38407ZM296.08875 116.75907L296.08875 110.54032L297.15125 110.54032L297.15125 116.75907L296.08875 116.75907ZM298.745 116.75907L298.745 110.54032L299.69812 110.54032L299.69812 111.47782Q300.0575 110.82157 300.36218 110.610634Q300.66687 110.3997 301.04187 110.3997Q301.57312 110.3997 302.12 110.72782L301.76062 111.7122Q301.37 111.47782 300.995 111.47782Q300.63562 111.47782 300.36218 111.68876Q300.08875 111.8997 299.97937 112.2747Q299.79187 112.8372 299.79187 113.49345L299.79187 116.75907L298.745 116.75907ZM306.82312 114.47782L307.85437 114.61845Q307.6825 115.68095 306.97937 116.29032Q306.27625 116.8997 305.26062 116.8997Q303.97937 116.8997 303.20593 116.06376Q302.4325 115.22782 302.4325 113.66532Q302.4325 112.66532 302.76843 111.90751Q303.10437 111.1497 303.78406 110.7747Q304.46375 110.3997 305.27625 110.3997Q306.27625 110.3997 306.92468 110.90751Q307.57312 111.41532 307.76062 112.36845L306.72937 112.5247Q306.58875 111.8997 306.21375 111.579384Q305.83875 111.25907 305.3075 111.25907Q304.51062 111.25907 304.01062 111.829384Q303.51062 112.3997 303.51062 113.63407Q303.51062 114.8997 303.995 115.4622Q304.47937 116.0247 305.245 116.0247Q305.87 116.0247 306.28406 115.6497Q306.69812 115.2747 306.82312 114.47782ZM308.72937 116.75907L308.72937 108.16532L309.79187 108.16532L309.79187 116.75907L308.72937 116.75907ZM315.66687 114.75907L316.76062 114.88407Q316.51062 115.8372 315.8075 116.36845Q315.10437 116.8997 314.02625 116.8997Q312.66687 116.8997 311.86218 116.05595Q311.0575 115.2122 311.0575 113.69657Q311.0575 112.13407 311.87 111.266884Q312.6825 110.3997 313.96375 110.3997Q315.21375 110.3997 316.0028 111.24345Q316.79187 112.0872 316.79187 113.63407Q316.79187 113.72782 316.79187 113.91532L312.15125 113.91532Q312.21375 114.94657 312.72937 115.485634Q313.245 116.0247 314.02625 116.0247Q314.60437 116.0247 315.01843 115.72001Q315.4325 115.41532 315.66687 114.75907ZM312.21375 113.05595L315.6825 113.05595Q315.62 112.25907 315.29187 111.86845Q314.77625 111.25907 313.97937 111.25907Q313.245 111.25907 312.7528 111.74345Q312.26062 112.22782 312.21375 113.05595Z" fill-rule="nonzero" fill="#000000"></path></svg>
+
diff --git a/testing/web-platform/tests/document-policy/experimental-features/resources/parser-blocking-script.js b/testing/web-platform/tests/document-policy/experimental-features/resources/parser-blocking-script.js
new file mode 100644
index 0000000000..c61efee8a0
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/resources/parser-blocking-script.js
@@ -0,0 +1 @@
+window.didExecuteExternalParsingBlockingScript = true;
diff --git a/testing/web-platform/tests/document-policy/experimental-features/resources/sync-script-test.js b/testing/web-platform/tests/document-policy/experimental-features/resources/sync-script-test.js
new file mode 100644
index 0000000000..65c1b21e6e
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/resources/sync-script-test.js
@@ -0,0 +1,9 @@
+var t = async_test('Test behavior of sync-script feature policy for different script types');
+
+window.onload = t.step_func(function() {
+ assert_equals(undefined, window.didExecuteInlineParsingBlockingScript, 'inline parser blocking script should be blocked');
+ assert_equals(undefined, window.didExecuteExternalParsingBlockingScript, 'external parser blocking script should be blocked');
+ assert_true(window.didExecuteExternalAsyncScript, 'external async script should not be blocked');
+ assert_true(window.didExecuteExternalDeferredScript, 'external defer script should not be blocked');
+ t.done();
+});
diff --git a/testing/web-platform/tests/document-policy/experimental-features/resources/video.ogv b/testing/web-platform/tests/document-policy/experimental-features/resources/video.ogv
new file mode 100644
index 0000000000..c9ee910fc6
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/resources/video.ogv
Binary files differ
diff --git a/testing/web-platform/tests/document-policy/experimental-features/sync-script.tentative.https.sub.html b/testing/web-platform/tests/document-policy/experimental-features/sync-script.tentative.https.sub.html
new file mode 100644
index 0000000000..a199a4ed3f
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/sync-script.tentative.https.sub.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<body>
+<script defer src="/resources/testharness.js"></script>
+<script defer src="/resources/testharnessreport.js"></script>
+<script>
+// The test harness scripts above are loaded as <script defer> because
+// they would be blocked if loaded synchronously.
+// Harness scripts should be evaluated before sync-script-test.js, so it
+// is also loaded as <script defer>
+//
+// The other scripts (both inline and external) are testing whether those
+// scripts are blocked or not.
+// sync-script-test.js asserts the results of the other scripts in onload
+// in order to guarantee that all scripts have either loaded or been blocked
+// before verifying the behavior.
+window.didExecuteInlineParsingBlockingScript = true;
+</script>
+<script src="/document-policy/experimental-features/resources/parser-blocking-script.js"></script>
+<script async src="/document-policy/experimental-features/resources/async-script.js"></script>
+<script defer src="/document-policy/experimental-features/resources/defer-script.js"></script>
+<script defer src="/document-policy/experimental-features/resources/sync-script-test.js"></script>
+</body>
diff --git a/testing/web-platform/tests/document-policy/experimental-features/sync-script.tentative.https.sub.html.headers b/testing/web-platform/tests/document-policy/experimental-features/sync-script.tentative.https.sub.html.headers
new file mode 100644
index 0000000000..cfe200c27b
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/sync-script.tentative.https.sub.html.headers
@@ -0,0 +1 @@
+Document-Policy: sync-script=?0
diff --git a/testing/web-platform/tests/document-policy/experimental-features/unsized-media.tentative.https.sub.html b/testing/web-platform/tests/document-policy/experimental-features/unsized-media.tentative.https.sub.html
new file mode 100644
index 0000000000..d7bb725249
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/unsized-media.tentative.https.sub.html
@@ -0,0 +1,95 @@
+<!DOCTYPE html>
+<body>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<iframe></iframe>
+<script>
+'use strict';
+const default_width = 300;
+const default_height = 150;
+const srcs = [
+ "/document-policy/experimental-features/resources/image.jpg",
+ "/document-policy/experimental-features/resources/image.png",
+ "/document-policy/experimental-features/resources/image.svg"
+];
+const test_cases = [
+// Test when no size is specified, img/video is laid out by the default size.
+{expected_width: default_width, expected_height: default_height},
+// Test when only one dimension is specified, img/video uses the default length for
+// the other dimension.
+{attribute: "width", value: 500, expected_width: 500, expected_height: 500 / 2},
+{attribute: "height", value: 800, expected_width: 800 * 2, expected_height: 800},
+// Test when only one dimension is specified by CSS style, img/video uses the
+// default length for the other dimension.
+{attribute: "style", value: "width:500px;", expected_width: 500, expected_height: 500 / 2},
+{attribute: "style", value: "height:800px;", expected_width: 800 * 2, expected_height: 800},
+// Test when the size of the image is specified, img/video is laid out by the
+// specified size.
+{attribute: "width", value: 500, attribute1: "height", value1: 800, expected_width: 500, expected_height:800},
+{attribute: "style", value: "width:500px;height:800px;", expected_width: 500, expected_height:800}
+];
+
+for (var test of test_cases) {
+ for (var src of srcs) {
+ async_test(t=> {
+ var img = document.createElement('IMG');
+ var expected_width = test.expected_width;
+ var expected_height = test.expected_height;
+ img.setAttribute("src", src);
+ if (typeof test.attribute !== "undefined") {
+ img.setAttribute(test.attribute, test.value);
+ }
+ if (typeof test.attribute1 !== "undefined") {
+ img.setAttribute(test.attribute1, test.value1);
+ }
+ img.addEventListener('load', t.step_func(function() {
+ assert_equals(img.width, expected_width, 'width:');
+ assert_equals(img.height, expected_height, 'height:');
+ t.done();
+ }));
+ document.body.appendChild(img);
+ }, 'Test image with attribute ' + test.attribute + '=' + test.value +
+ ' and attribute ' + test.attribute1 + '=' + test.value1 + ' on src ' + src);
+ }
+ async_test(t=> {
+ var video = document.createElement('video');
+ video.addEventListener('canplaythrough', t.step_func(function() {
+ assert_equals(video.getBoundingClientRect().width, expected_width, 'width:');
+ assert_equals(video.getBoundingClientRect().height, expected_height, 'height:');
+ t.done();
+ }));
+ var expected_width = test.expected_width;
+ var expected_height = test.expected_height;
+ video.setAttribute("src", "/document-policy/experimental-features/resources/video.ogv");
+ if (typeof test.attribute !== "undefined") {
+ video.setAttribute(test.attribute, test.value);
+ }
+ if (typeof test.attribute1 !== "undefined") {
+ video.setAttribute(test.attribute1, test.value1);
+ }
+ document.body.appendChild(video);
+ }, 'Test video with attribute ' + test.attribute + '=' + test.value +
+ ' and attribute ' + test.attribute1 + '=' + test.value1);
+}
+
+// Subframes do not inherit document policy from parent frame.
+// Unsized-Media should not work in subframes.
+var iframe = document.querySelector('iframe');
+var iframe_srcs = [
+ "/document-policy/experimental-features/resources/document-policy-image.html",
+ "https://{{domains[www]}}:{{ports[https][0]}}/document-policy/experimental-features/resources/document-policy-image.html"];
+for (var src of iframe_srcs) {
+ promise_test(function() {
+ iframe.src = src;
+ return new Promise(function(resolve, reject) {
+ window.addEventListener('message', function(e) {
+ resolve(e.data);
+ });
+ }).then(function(data) {
+ assert_not_equals(data.width, default_width, 'width');
+ assert_not_equals(data.height, default_height, 'height');
+ });
+ }, 'Test image size is correctly rendered in iframe of src ' + src);
+}
+</script>
+</body>
diff --git a/testing/web-platform/tests/document-policy/experimental-features/unsized-media.tentative.https.sub.html.headers b/testing/web-platform/tests/document-policy/experimental-features/unsized-media.tentative.https.sub.html.headers
new file mode 100644
index 0000000000..cf59933e8d
--- /dev/null
+++ b/testing/web-platform/tests/document-policy/experimental-features/unsized-media.tentative.https.sub.html.headers
@@ -0,0 +1 @@
+Document-Policy: unsized-media=?0