diff options
Diffstat (limited to 'testing/web-platform/tests/html/semantics/document-metadata/the-meta-element')
37 files changed, 747 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-attribute-changes.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-attribute-changes.html new file mode 100644 index 0000000000..6f877ee416 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-attribute-changes.html @@ -0,0 +1,35 @@ +<!doctype html> +<title>Meta color-scheme - attribute changes</title> +<meta id="meta" name="color-scheme" content="dark"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/compute-root-color-scheme.js"></script> +<!-- + NOTE: This test assumes that the browser's default color-scheme is "light", + see https://github.com/web-platform-tests/wpt/pull/31268 for reasoning +--> +<script> + assert_root_color_scheme("dark", "Meta color-scheme initially 'dark'."); + + meta.removeAttribute("name"); + assert_root_color_scheme("light", "Removed name attribute from meta color-scheme."); + + meta.setAttribute("name", "color-scheme"); + assert_root_color_scheme("dark", "Set meta name to color-scheme."); + + meta.setAttribute("content", ""); + assert_root_color_scheme("light", "Set content attribute of meta color-scheme to empty string."); + + meta.setAttribute("content", ",,invalid"); + assert_root_color_scheme("light", "Set content attribute of meta color-scheme to an invalid value."); + + meta.setAttribute("content", "light"); + assert_root_color_scheme("light", "Set content attribute of meta color-scheme to 'light'."); + + meta.setAttribute("content", "dark"); + assert_root_color_scheme("dark", "Set content attribute of meta color-scheme to 'dark'."); + + meta.removeAttribute("content"); + assert_root_color_scheme("light", "Removed the content attribute of meta color-scheme."); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-empty-content-value.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-empty-content-value.html new file mode 100644 index 0000000000..8a3cf18af8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-empty-content-value.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>Meta color-scheme - empty content value</title> +<meta name="color-scheme" content=""> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/compute-root-color-scheme.js"></script> +<!-- + NOTE: This test assumes that the browser's default color-scheme is "light", + see https://github.com/web-platform-tests/wpt/pull/31268 for reasoning +--> +<script> + assert_root_color_scheme("light", "Meta color-scheme with empty content attribute has no effect."); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-first-valid-applies.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-first-valid-applies.html new file mode 100644 index 0000000000..095d0f360d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-first-valid-applies.html @@ -0,0 +1,16 @@ +<!doctype html> +<title>Multiple color-scheme meta tags - first valid applies</title> +<meta name="color-scheme"> +<meta name="color-scheme" content> +<meta name="color-scheme" content=""> +<meta name="color-scheme" content="light,dark"> +<!-- This is first with a valid content value --> +<meta name="color-scheme" content="dark"> +<meta name="color-scheme" content="light"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/compute-root-color-scheme.js"></script> +<script> + assert_root_color_scheme("dark", "Tree order decides which meta color-scheme applies."); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-insert.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-insert.html new file mode 100644 index 0000000000..463c318105 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-insert.html @@ -0,0 +1,26 @@ +<!doctype html> +<title>Insert color-scheme meta tags</title> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/compute-root-color-scheme.js"></script> +<!-- + NOTE: This test assumes that the browser's default color-scheme is "light", + see https://github.com/web-platform-tests/wpt/pull/31268 for reasoning +--> +<script> + function createMeta(content) { + const meta = document.createElement("meta"); + meta.setAttribute("name", "color-scheme"); + meta.setAttribute("content", content); + return meta; + } + + assert_root_color_scheme("light", "Initial color-scheme"); + + document.head.appendChild(createMeta("dark")); + assert_root_color_scheme("dark", "Inserted meta color-scheme applies"); + + document.head.insertBefore(createMeta("light"), document.head.lastChild); + assert_root_color_scheme("light", "Inserted meta color-scheme before existing in head applies"); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-no-content-value.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-no-content-value.html new file mode 100644 index 0000000000..0d22e44b26 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-no-content-value.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>Meta color-scheme - no content value</title> +<meta name="color-scheme"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/compute-root-color-scheme.js"></script> +<!-- + NOTE: This test assumes that the browser's default color-scheme is "light", + see https://github.com/web-platform-tests/wpt/pull/31268 for reasoning +--> +<script> + assert_root_color_scheme("light", "Meta color-scheme without content attribute has no effect."); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-normal-descendant-change.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-normal-descendant-change.html new file mode 100644 index 0000000000..136f4c371b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-normal-descendant-change.html @@ -0,0 +1,20 @@ +<!doctype html> +<title>Change color-scheme meta tag affecting normal descendant</title> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<meta id="meta" name="color-scheme" content="dark"> +<div style="color-scheme: dark; color: CanvasText" id="dark"> + <div style="color-scheme: normal; color: CanvasText" id="normal"></div> +</div> +<script> + test(() => { + assert_equals(getComputedStyle(dark).color, getComputedStyle(normal).color); + }, "Normal initially dark"); + + meta.content = "light"; + + test(() => { + assert_not_equals(getComputedStyle(dark).color, getComputedStyle(normal).color); + }, "Normal should change to light from page color schemes"); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-remove-head.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-remove-head.html new file mode 100644 index 0000000000..587e2fa596 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-remove-head.html @@ -0,0 +1,17 @@ +<!doctype html> +<title>Remove head with meta color-scheme</title> +<meta name="color-scheme" content="dark"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/compute-root-color-scheme.js"></script> +<!-- + NOTE: This test assumes that the browser's default color-scheme is "light", + see https://github.com/web-platform-tests/wpt/pull/31268 for reasoning +--> +<body></body> +<script> + assert_root_color_scheme("dark", "Meta color-scheme applies."); + document.head.remove(); + assert_root_color_scheme("light", "Initial value after removing head including meta color-scheme."); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-remove.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-remove.html new file mode 100644 index 0000000000..a89a520791 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-remove.html @@ -0,0 +1,19 @@ +<!doctype html> +<title>Remove color-scheme meta tag</title> +<meta id="dark" name="color-scheme" content="dark"> +<meta id="light" name="color-scheme" content="light"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/compute-root-color-scheme.js"></script> +<!-- + NOTE: This test assumes that the browser's default color-scheme is "light", + see https://github.com/web-platform-tests/wpt/pull/31268 for reasoning +--> +<script> + assert_root_color_scheme("dark", "First meta applies."); + dark.remove(); + assert_root_color_scheme("light", "Second meta applies after first one is removed."); + light.remove(); + assert_root_color_scheme("light", "Initial color-scheme with both meta elements removed."); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-single-value-in-body.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-single-value-in-body.html new file mode 100644 index 0000000000..19f8d53994 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-single-value-in-body.html @@ -0,0 +1,12 @@ +<!doctype html> +<title>Meta color-scheme in body should apply</title> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/compute-root-color-scheme.js"></script> +<body> + <meta name="color-scheme" content="dark"> +</body> +<script> + assert_root_color_scheme("dark", "Meta color-scheme in body should apply."); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-single-value-in-head.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-single-value-in-head.html new file mode 100644 index 0000000000..b9fd2c4384 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-single-value-in-head.html @@ -0,0 +1,10 @@ +<!doctype html> +<title>Single meta color-scheme in head</title> +<meta name="color-scheme" content="dark"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/compute-root-color-scheme.js"></script> +<script> + assert_root_color_scheme("dark", "Meta color-scheme in head applies."); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-single-value-in-shadow-tree.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-single-value-in-shadow-tree.html new file mode 100644 index 0000000000..7ccafc8419 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-single-value-in-shadow-tree.html @@ -0,0 +1,22 @@ +<!doctype html> +<title>Meta color-scheme in shadow-tree should not apply</title> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/compute-root-color-scheme.js"></script> +<!-- + NOTE: This test assumes that the browser's default color-scheme is "light", + see https://github.com/web-platform-tests/wpt/pull/31268 for reasoning +--> +<script> + const host = document.createElement("div"); + host.id = "host"; + document.head.appendChild(host); + const root = host.attachShadow({mode:"open"}); + const meta = document.createElement("meta"); + meta.setAttribute("name", "color-scheme"); + meta.setAttribute("content", "dark"); + root.appendChild(meta); + + assert_root_color_scheme("light", "Meta color-scheme in shadow tree does not apply."); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/support/compute-root-color-scheme.js b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/support/compute-root-color-scheme.js new file mode 100644 index 0000000000..74cbf895ce --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/color-scheme/support/compute-root-color-scheme.js @@ -0,0 +1,28 @@ +'use strict'; + +function assert_root_color_scheme(expected_used_scheme, description) { + function get_used_root_color_scheme() { + let light = get_system_color("only light", "CanvasText"); + let dark = get_system_color("only dark", "CanvasText"); + assert_not_equals(light, dark, "CanvasText system color should be different with light and dark color schemes"); + let root = getComputedStyle(document.documentElement).color; + assert_in_array(root, [light, dark], "Root color scheme should be either light or dark, or the text needs to be extended for newer color-schemes"); + return root == light ? "light" : "dark"; + } + + function get_system_color(scheme, color) { + let div = document.createElement("div"); + div.style.color = color; + div.style.colorScheme = scheme; + + document.documentElement.appendChild(div); + let computed = getComputedStyle(div).color; + div.remove(); + return computed; + } + + test(() => { + assert_equals(get_used_root_color_scheme(), expected_used_scheme); + assert_equals(getComputedStyle(document.documentElement).colorScheme, "normal", "Root element's color-scheme should be 'normal'"); + }, description); +} diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/http-equiv-and-name-1.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/http-equiv-and-name-1.html new file mode 100644 index 0000000000..ac82e3396d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/http-equiv-and-name-1.html @@ -0,0 +1,23 @@ +<!doctype html> +<title>Setting both http-equiv and name attributes on a meta element</title> +<meta http-equiv=content-language name=color-scheme content=dark> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="color-scheme/support/compute-root-color-scheme.js"></script> +<!-- + NOTE: This test assumes that the browser's default color-scheme is "light", + see https://github.com/web-platform-tests/wpt/pull/31268 for reasoning +--> +<script> + // This creates a test() + assert_root_color_scheme("dark", "<meta> set the color-scheme to dark"); + + // We can't test content-language against :lang(), because CSS Selectors 4 + // references BCP 47 syntax and RFC4647 "Matching of Language Tags", but + // "dark" is not a well-formed BCP 47 tag and therefore cannot be matched. + // Therefore, the test that content-language gets set is split off to a + // separate testcase using a well-formed lang tag as the content. + // test(() => { + // assert_equals(document.querySelector(":root:lang(dark)"), document.documentElement); + // }, "<meta> set the content-language to dark"); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/http-equiv-and-name-2.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/http-equiv-and-name-2.html new file mode 100644 index 0000000000..b73013a341 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/http-equiv-and-name-2.html @@ -0,0 +1,13 @@ +<!doctype html> +<title>Setting both http-equiv and name attributes on a meta element</title> +<meta http-equiv=content-language name=color-scheme content=de-DE> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + // We don't attempt to test the color-scheme here because "de-DE" is not a valid + // value for it. + + test(() => { + assert_equals(document.querySelector(":root:lang(de-DE)"), document.documentElement); + }, "<meta> set the content-language to de-DE"); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/allow-scripts-flag-changing-1.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/allow-scripts-flag-changing-1.html new file mode 100644 index 0000000000..196f6d0409 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/allow-scripts-flag-changing-1.html @@ -0,0 +1,57 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Meta refresh is blocked by the allow-scripts sandbox flag at its creation time, not when refresh comes due</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-refresh"> + +<div id="log"></div> + +<script> +"use strict"; +setup({ single_test: true }); + +const sourceIFrame = document.createElement("iframe"); +sourceIFrame.setAttribute("sandbox", "allow-same-origin"); + +const destIFrame = document.createElement("iframe"); + +let sourceLoadCount = 0; +let destLoadCount = 0; + +sourceIFrame.onload = () => { + ++sourceLoadCount; + + if (sourceLoadCount === 2) { + assert_unreached("The iframe from which the meta came from must not refresh"); + } + + maybeStartTest(); +}; + +destIFrame.onload = () => { + ++destLoadCount; + + if (destLoadCount === 2) { + // destIFrame doesn't have the sandboxed automatic features browsing context + // flag sets, thus navigated. + assert_equals(destIFrame.contentDocument.body.textContent.trim(), "foo"); + done(); + } + + maybeStartTest(); +}; + +function maybeStartTest() { + if (sourceLoadCount === 1 && destLoadCount === 1) { + const meta = sourceIFrame.contentDocument.querySelector("meta"); + destIFrame.contentDocument.body.appendChild(meta); + } +} + +sourceIFrame.src = "support/refresh.sub.html?input=" + encodeURIComponent("1; url=foo"); +destIFrame.src = "support/ufoo"; + +document.body.appendChild(sourceIFrame); +document.body.appendChild(destIFrame); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/allow-scripts-flag-changing-2.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/allow-scripts-flag-changing-2.html new file mode 100644 index 0000000000..cc7eb5e5e0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/allow-scripts-flag-changing-2.html @@ -0,0 +1,55 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Meta refresh of the original iframe is not blocked if moved into a sandboxed iframe</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-refresh"> + +<div id="log"></div> + +<script> +"use strict"; +setup({ single_test: true }); + +const sourceIFrame = document.createElement("iframe"); + +const destIFrame = document.createElement("iframe"); +destIFrame.setAttribute("sandbox", "allow-same-origin"); + +let sourceLoadCount = 0; +let destLoadCount = 0; + +sourceIFrame.onload = () => { + ++sourceLoadCount; + + if (sourceLoadCount === 2) { + assert_equals(sourceIFrame.contentDocument.body.textContent.trim(), "foo"); + done(); + } + + maybeStartTest(); +}; + +destIFrame.onload = () => { + ++destLoadCount; + + if (destLoadCount === 2) { + assert_unreached("The iframe into which the meta was moved must not refresh"); + } + + maybeStartTest(); +}; + +function maybeStartTest() { + if (sourceLoadCount === 1 && destLoadCount === 1) { + const meta = sourceIFrame.contentDocument.querySelector("meta"); + destIFrame.contentDocument.body.appendChild(meta); + } +} + +sourceIFrame.src = "support/refresh.sub.html?input=" + encodeURIComponent("1; url=foo"); +destIFrame.src = "support/ufoo"; + +document.body.appendChild(sourceIFrame); +document.body.appendChild(destIFrame); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/dynamic-append.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/dynamic-append.html new file mode 100644 index 0000000000..4d2fa78940 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/dynamic-append.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Meta refresh applies even when dynamically appended</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#pragma-directives"> + +<div id="log"></div> + +<script> +"use strict"; +setup({ single_test: true }); + +const iframe = document.createElement("iframe"); +let loadCount = 0; + +iframe.onload = () => { + ++loadCount; + const iDocument = iframe.contentDocument; + + if (loadCount === 1) { + iDocument.body.innerHTML = `<meta http-equiv="refresh" content="1; url=foo">`; + } else if (loadCount === 2) { + assert_equals(iDocument.body.textContent.trim(), "foo"); + done(); + } +}; + +iframe.src = "support/ufoo"; +document.body.appendChild(iframe); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/not-in-shadow-tree.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/not-in-shadow-tree.html new file mode 100644 index 0000000000..2a9f301fff --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/not-in-shadow-tree.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Meta refresh only applies while in the document tree, not in a shadow tree</title> +<meta name="timeout" content="long" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#pragma-directives"> + +<div id="log"></div> +<script> +"use strict"; +setup({ single_test: true }); + +const iframe = document.createElement("iframe"); +iframe.src = "support/ufoo"; + +let loadCount = 0; + +iframe.onload = () => { + ++loadCount; + const iDocument = iframe.contentDocument; + + if (loadCount === 1) { + const div = iDocument.createElement("div"); + assert_true('attachShadow' in div, 'attachShadow support'); + const shadowRoot = div.attachShadow({ mode: "open" }); + shadowRoot.innerHTML = `<meta http-equiv="refresh" content="1; url=foo">`; + iDocument.body.appendChild(div); + + // Want to make sure no refreshes happen + step_timeout(done, 3000); + } else { + assert_unreached("Got more than 1 load event"); + } +}; + +document.body.appendChild(iframe); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html new file mode 100644 index 0000000000..73ac4bcc00 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/parsing.html @@ -0,0 +1,147 @@ +<!doctype html> +<meta charset=utf-8> +<meta name="variant" content="?1-10"> +<meta name="variant" content="?11-20"> +<meta name="variant" content="?21-30"> +<meta name="variant" content="?31-40"> +<meta name="variant" content="?41-50"> +<meta name="variant" content="?51-60"> +<meta name="variant" content="?61-70"> +<meta name="variant" content="?71-80"> +<meta name="variant" content="?81-90"> +<meta name="variant" content="?91-100"> +<meta name="variant" content="?101-110"> +<meta name="variant" content="?111-120"> +<meta name="variant" content="?121-130"> +<meta name="variant" content="?131-last"> +<title>Parsing of meta refresh</title> +<meta name="timeout" content="long"> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src=/common/subset-tests.js></script> +<style> +iframe { display:none } +</style> +<body> +<script> + +// failure to parse is [] +// success to parse is [time, url] where url is unresolved + +var tests_arr = [ + {input: '', expected: []}, + {input: '1', expected: [1, '__filename__']}, + {input: '1 ', expected: [1, '__filename__']}, + {input: '1\t', expected: [1, '__filename__']}, + {input: '1\r', expected: [1, '__filename__']}, + {input: '1\n', expected: [1, '__filename__']}, + {input: '1\f', expected: [1, '__filename__']}, + {input: '1;', expected: [1, '__filename__']}, + {input: '1,', expected: [1, '__filename__']}, + {input: '1; url=foo', expected: [1, 'foo']}, + {input: '1, url=foo', expected: [1, 'foo']}, + {input: '1 url=foo', expected: [1, 'foo']}, + {input: '1;\turl=foo', expected: [1, 'foo']}, + {input: '1,\turl=foo', expected: [1, 'foo']}, + {input: '1\turl=foo', expected: [1, 'foo']}, + {input: '1;\rurl=foo', expected: [1, 'foo']}, + {input: '1,\rurl=foo', expected: [1, 'foo']}, + {input: '1\rurl=foo', expected: [1, 'foo']}, + {input: '1;\nurl=foo', expected: [1, 'foo']}, + {input: '1,\nurl=foo', expected: [1, 'foo']}, + {input: '1\nurl=foo', expected: [1, 'foo']}, + {input: '1;\furl=foo', expected: [1, 'foo']}, + {input: '1,\furl=foo', expected: [1, 'foo']}, + {input: '1\furl=foo', expected: [1, 'foo']}, + {input: '1url=foo', expected: []}, + {input: '1x;url=foo', expected: []}, + {input: '1 x;url=foo', expected: [1, 'x;url=foo']}, + {input: '1;;url=foo', expected: [1, ';url=foo']}, + {input: ' 1 ; url = foo', expected: [1, 'foo']}, + {input: ' 1 , url = foo', expected: [1, 'foo']}, + {input: ' 1 ; foo', expected: [1, 'foo']}, + {input: ' 1 , foo', expected: [1, 'foo']}, + {input: ' 1 url = foo', expected: [1, 'foo']}, + {input: '1; url=foo ', expected: [1, 'foo']}, + {input: '1; url=f\to\no', expected: [1, 'foo']}, + {input: '1; url="foo"bar', expected: [1, 'foo']}, + {input: '1; url=\'foo\'bar', expected: [1, 'foo']}, + {input: '1; url="foo\'bar', expected: [1, 'foo\'bar']}, + {input: '1; url foo', expected: [1, 'url foo']}, + {input: '1; urlfoo', expected: [1, 'urlfoo']}, + {input: '1; urfoo', expected: [1, 'urfoo']}, + {input: '1; ufoo', expected: [1, 'ufoo']}, + {input: '1; "foo"bar', expected: [1, 'foo']}, + {input: '; foo', expected: []}, + {input: ';foo', expected: []}, + {input: ', foo', expected: []}, + {input: ',foo', expected: []}, + {input: 'foo', expected: []}, + {input: '+1; url=foo', expected: []}, + {input: '-1; url=foo', expected: []}, + {input: '+0; url=foo', expected: []}, + {input: '-0; url=foo', expected: []}, + {input: '0; url=foo', expected: [0, 'foo']}, + {input: '+1; foo', expected: []}, + {input: '-1; foo', expected: []}, + {input: '+0; foo', expected: []}, + {input: '-0; foo', expected: []}, + {input: '0; foo', expected: [0, 'foo']}, + {input: '+1', expected: []}, + {input: '-1', expected: []}, + {input: '+0', expected: []}, + {input: '-0', expected: []}, + {input: '0', expected: [0, '__filename__']}, + {input: '1.9; url=foo', expected: [1, 'foo']}, + {input: '1.9..5.; url=foo', expected: [1, 'foo']}, + {input: '.9; url=foo', expected: [0, 'foo']}, + {input: '0.9; url=foo', expected: [0, 'foo']}, + {input: '0...9; url=foo', expected: [0, 'foo']}, + {input: '0...; url=foo', expected: [0, 'foo']}, + {input: '1e0; url=foo', expected: []}, + {input: '1e1; url=foo', expected: []}, + {input: '10e-1; url=foo', expected: []}, + {input: '-0.1; url=foo', expected: []}, +]; + +tests_arr.forEach(function(test_obj) { + ["<meta>", "Refresh header"].forEach(type => { + if(type === "Refresh header" && test_obj.input.match("[\n\r\f]")) { // See https://github.com/web-platform-tests/wpt/issues/8372 for why \f as well + return; + } + const filename = type === "<meta>" ? "refresh.sub.html" : "refresh.py"; + subsetTest(async_test, function(t) { + var iframe = document.createElement('iframe'); + t.add_cleanup(function() { + document.body.removeChild(iframe); + }); + iframe.src = "support/" + filename + "?input=" + encodeURIComponent(test_obj.input); + document.body.appendChild(iframe); + var loadCount = 0; + iframe.onload = t.step_func(function() { + loadCount++; + var got = iframe.contentDocument.body.textContent.trim(); + if (test_obj.expected.length === 0) { + assert_equals(got, filename); + if (loadCount === 1) { + t.step_timeout(function() { + t.done(); + }, 3000); // want to make sure it doesn't redirect when it shouldn't + } else { + assert_unreached('Got > 1 load events'); + } + } else { + if (loadCount === 2) { + if(test_obj.expected[1] === "__filename__") { + assert_equals(got, filename); + } else { + assert_equals(got, test_obj.expected[1]); + } + t.done(); + } + } + }); + }, type + ": " + format_value(test_obj.input)); + }); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/remove-from-document.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/remove-from-document.html new file mode 100644 index 0000000000..1e608a3456 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/remove-from-document.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>A meta must refresh the original document even if it was removed.</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-refresh"> + +<div id="log"></div> + +<script> +"use strict"; +setup({ single_test: true }); + +const sourceIFrame = document.createElement("iframe"); +let sourceLoadCount = 0; + +sourceIFrame.onload = () => { + ++sourceLoadCount; + + if (sourceLoadCount === 2) { + assert_equals(sourceIFrame.contentDocument.body.textContent.trim(), "foo"); + done(); + } + + maybeStartTest(); +}; + +function maybeStartTest() { + if (sourceLoadCount === 1) { + sourceIFrame.contentDocument.querySelector("meta").remove(); + } +} + +sourceIFrame.src = "support/refresh.sub.html?input=" + encodeURIComponent("1; url=foo"); + +document.body.appendChild(sourceIFrame); +</script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/;url=foo b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/;url=foo new file mode 100644 index 0000000000..622ff110d3 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/;url=foo @@ -0,0 +1 @@ +;url=foo diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/__dir__.headers b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/__dir__.headers new file mode 100644 index 0000000000..156209f9c8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/__dir__.headers @@ -0,0 +1 @@ +Content-Type: text/html diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/foo b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/foo new file mode 100644 index 0000000000..257cc5642c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/foo @@ -0,0 +1 @@ +foo diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/foo'bar b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/foo'bar new file mode 100644 index 0000000000..80e7410879 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/foo'bar @@ -0,0 +1 @@ +foo'bar diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/refresh.py b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/refresh.py new file mode 100644 index 0000000000..797c7b9412 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/refresh.py @@ -0,0 +1,4 @@ +def main(request, response): + response.headers.set(b"Content-Type", b"text/html") + response.headers.set(b"Refresh", request.GET.first(b"input")) + response.content = u"<!doctype html>refresh.py\n" diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/refresh.sub.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/refresh.sub.html new file mode 100644 index 0000000000..bc97f29c62 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/refresh.sub.html @@ -0,0 +1 @@ +<!doctype html><meta http-equiv=refresh content="{{GET[input]}}">refresh.sub.html diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/ufoo b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/ufoo new file mode 100644 index 0000000000..8fff3cf4fb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/ufoo @@ -0,0 +1 @@ +ufoo diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/urfoo b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/urfoo new file mode 100644 index 0000000000..7d7373f4b7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/urfoo @@ -0,0 +1 @@ +urfoo diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/url foo b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/url foo new file mode 100644 index 0000000000..a1e6a92290 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/url foo @@ -0,0 +1 @@ +url foo diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/urlfoo b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/urlfoo new file mode 100644 index 0000000000..3e67b2f7ca --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/urlfoo @@ -0,0 +1 @@ +urlfoo diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/x;url=foo b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/x;url=foo new file mode 100644 index 0000000000..f10371aa7b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/x;url=foo @@ -0,0 +1 @@ +x;url=foo diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-lower.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-lower.html new file mode 100644 index 0000000000..026e61c2ca --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-lower.html @@ -0,0 +1,5 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<meta http-equiv="content-security-policy" content="script-src 'self'"> +<script>inline = true;</script> +<script src="http-equiv-enumerated-ascii-case-insensitive-message.js"></script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-message.js b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-message.js new file mode 100644 index 0000000000..1dc218a0a5 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-message.js @@ -0,0 +1 @@ +parent.postMessage(null, "*"); diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-mixed.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-mixed.html new file mode 100644 index 0000000000..b4c547d342 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-mixed.html @@ -0,0 +1,5 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<meta http-equiv="CoNtEnT-sEcUrItY-pOlIcY" content="script-src 'self'"> +<script>inline = true;</script> +<script src="http-equiv-enumerated-ascii-case-insensitive-message.js"></script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-other.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-other.html new file mode 100644 index 0000000000..5c89a5e8bc --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive-other.html @@ -0,0 +1,5 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<meta http-equiv="content-ſecurity-policy" content="script-src 'self'"> +<script>inline = true;</script> +<script src="http-equiv-enumerated-ascii-case-insensitive-message.js"></script> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive.html new file mode 100644 index 0000000000..6d19be4149 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/pragma-directives/http-equiv-enumerated-ascii-case-insensitive.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<link rel="help" href="https://html.spec.whatwg.org/#attr-meta-http-equiv"> +<link rel="help" href="https://html.spec.whatwg.org/#enumerated-attribute"> +<meta name="assert" content="meta@http-equiv values are ASCII case-insensitive"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +async_test(function() { + let loaded = 0; + + // we use a message rather than the iframe’s load event to avoid dealing with + // spurious load events that some browsers dispatch on the initial about:blank + addEventListener("message", this.step_func(event => { + if (++loaded == 3) { + const iframe = document.querySelectorAll("iframe"); + + assert_equals(iframe[0].contentWindow.inline, + undefined, "lowercase valid"); + assert_equals(iframe[1].contentWindow.inline, + undefined, "mixed case valid"); + assert_equals(iframe[2].contentWindow.inline, + true, "non-ASCII invalid"); + + this.done(); + } + })); +}, "keyword content-security-policy"); +</script> +<iframe src="http-equiv-enumerated-ascii-case-insensitive-lower.html"></iframe> +<iframe src="http-equiv-enumerated-ascii-case-insensitive-mixed.html"></iframe> +<iframe src="http-equiv-enumerated-ascii-case-insensitive-other.html"></iframe> diff --git a/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/the-lang-attribute-012.html b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/the-lang-attribute-012.html new file mode 100644 index 0000000000..af872d6e3a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/the-meta-element/the-lang-attribute-012.html @@ -0,0 +1,51 @@ +<!DOCTYPE html> +<html > +<head> +<meta charset="utf-8"/> + <meta http-equiv="Content-Language" content="ko,zh,ja" > +<title>Multiple languages in Content-Language meta element</title> +<link rel='author' title='Richard Ishida' href='mailto:ishida@w3.org'> +<link rel='help' href='https://html.spec.whatwg.org/multipage/#pragma-directives'> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<meta name='flags' content='dom'> +<style type='text/css'> + #colonlangcontroltest { color: red; font-weight: bold; width: 400px; } + #colonlangcontroltest:lang(xx) { display:none; } +.test div { width: 50px; } + +#box:lang(ko) { width: 100px; } +#box:lang(zh) { width: 100px; } +#box:lang(ja) { width: 100px; } + + /* styling for debugging related notes */ + .notes span:lang(ko) { background-color: #0000FF; color: white; padding: 0 5px; } + .notes span:lang(zh) { background-color: #0000FF; color: white; padding: 0 5px; } + .notes span:lang(ja) { background-color: #0000FF; color: white; padding: 0 5px; } + +</style> +</head> +<body> + + + +<div class="test"><div id="box"> </div></div> +<p lang='xx' id='colonlangcontroltest'>This test failed because it relies on :lang for results, but :lang is not supported by this browser.</p> + + +<!--Notes: + +This test uses :lang to detect whether the language has been set. If :lang is not supported, a message will appear and the test will fail. + +--> +<script> +test(function() { +assert_equals(document.getElementById('colonlangcontroltest').offsetWidth, 0) +assert_equals(document.getElementById('box').offsetWidth, 50); +}, "The UA will not recognize a language declaration in the Content-Language meta element when more than one language is declared."); +</script> + +<div id='log'></div> + +</body> +</html> |