Bug 1476542 [wpt PR 12049] - Window, LocalDomWindow and Document open() functions modified to accept TrustedTypes, a=testonly
Automatic update from web-platform-testsWindow, LocalDomWindow and Document open() functions modified to accept
TrustedTypes
Changed open() definitions in .idl files.
Introduced new implementations of LocalDomWindow::open(), old versions
renamed openFromString and moved to private section.
Changed definition of 3-argument version of Document::open.
Bug: 739170
Change-Id: I64931c5e95eaa9dd2d2aab19ccb0bf8896621e7d
Reviewed-on: https://chromium-review.googlesource.com/1141581
Reviewed-by: Mike West <mkwst@chromium.org>
Commit-Queue: Maja Kabus <kabusm@google.com>
Cr-Commit-Position: refs/heads/master@{#576398}
--
wpt-commits: a6e4d3fc416ef91ed9aa856522a2255608da2c30
wpt-pr: 12049
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -379999,16 +379999,22 @@
]
],
"trusted-types/block-string-assignment-to-script-src.tentative.html": [
[
"/trusted-types/block-string-assignment-to-script-src.tentative.html",
{}
]
],
+ "trusted-types/block-string-assignment-to-window-open.tentative.html": [
+ [
+ "/trusted-types/block-string-assignment-to-window-open.tentative.html",
+ {}
+ ]
+ ],
"trusted-types/createContextualFragment.tentative.html": [
[
"/trusted-types/createContextualFragment.tentative.html",
{}
]
],
"trusted-types/document-write.tentative.html": [
[
@@ -380071,16 +380077,22 @@
]
],
"trusted-types/srcDoc.tentative.html": [
[
"/trusted-types/srcDoc.tentative.html",
{}
]
],
+ "trusted-types/window-open.tentative.html": [
+ [
+ "/trusted-types/window-open.tentative.html",
+ {}
+ ]
+ ],
"uievents/constructors/inputevent-constructor.html": [
[
"/uievents/constructors/inputevent-constructor.html",
{}
]
],
"uievents/interface/click-event.htm": [
[
@@ -620852,16 +620864,20 @@
"trusted-types/block-string-assignment-to-outerHTML.tentative.html": [
"e45a6ea12e10693fb9c77e28e76e62a0c733d3da",
"testharness"
],
"trusted-types/block-string-assignment-to-script-src.tentative.html": [
"da38712c6e43d1e6fe5892a5339a45c4bf438c7e",
"testharness"
],
+ "trusted-types/block-string-assignment-to-window-open.tentative.html": [
+ "210a8b4968f4976dca5316876228debbc3d9ddfa",
+ "testharness"
+ ],
"trusted-types/createContextualFragment.tentative.html": [
"e98f5e7fa6feeb5000a6310377ea82041c87e27d",
"testharness"
],
"trusted-types/document-write.tentative.html": [
"d4097e6235d0a8ddd28c9cfde4b985fb61e6ace9",
"testharness"
],
@@ -620904,16 +620920,20 @@
"trusted-types/srcDoc.tentative.html": [
"c13a940e03f51dacfbed5036be81356ef4fe72e5",
"testharness"
],
"trusted-types/support/helper.sub.js": [
"6162bad41b15d0ae0be727b5d960bb538d430fe2",
"support"
],
+ "trusted-types/window-open.tentative.html": [
+ "bbdc214490d471285f9b086cd0b98eb8a765691a",
+ "testharness"
+ ],
"uievents/META.yml": [
"a6706289064c1bbabcfab6540831084fc39fb94a",
"support"
],
"uievents/README.md": [
"bf426dc592940dbabd23db6c2343bcc5d29dc4b8",
"support"
],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/trusted-types/block-string-assignment-to-window-open.tentative.html
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="support/helper.sub.js"></script>
+
+ <meta http-equiv="Content-Security-Policy" content="require-trusted-types">
+</head>
+<body>
+<script>
+ //helper functions for the tests
+ function testWindowOpen(t, url, win) {
+ let child_window = win.open(url, "", "");
+ child_window.onload = t.step_func_done(_ => {
+ assert_equals(child_window.location.href, "" + url);
+ child_window.close();
+ });
+ }
+
+ function testWindowThrows(t, url, win) {
+ let child_window = win.open(TrustedURL.create(URLS.safe), "", "");
+ child_window.onload = t.step_func_done(_ => {
+ assert_throws(new TypeError(), _ => {
+ child_window = win.open(url, "", "");
+ child_window.close();
+ });
+ });
+ }
+
+ //TrustedURL assignments do not throw
+ async_test(t => {
+ testWindowOpen(t, TrustedURL.create(URLS.safe), window);
+ }, "window.open: safe URL, safe construction.");
+
+ async_test(t => {
+ testWindowOpen(t, TrustedURL.unsafelyCreate(URLS.safe), window);
+ }, "window.open: safe URL, unsafe construction.");
+
+ async_test(t => {
+ testWindowOpen(t, TrustedURL.create(URLS.safe), document);
+ }, "document.open: safe URL, safe construction.");
+
+ async_test(t => {
+ testWindowOpen(t, TrustedURL.unsafelyCreate(URLS.safe), document);
+ }, "document.open: safe URL, unsafe construction.");
+
+ //String assignments throw
+ async_test(t => {
+ testWindowThrows(t, 'A string', window);
+ }, "`window.open(string)` throws.");
+
+ async_test(t => {
+ testWindowThrows(t, 'A string', document);
+ }, "`document.open(string)` throws.");
+
+ //Null assignment throws
+ async_test(t => {
+ testWindowThrows(t, null, window);
+ }, "`window.open(null)` throws.");
+
+ //Null assignment throws
+ async_test(t => {
+ testWindowThrows(t, null, document);
+ }, "`document.open(null)` throws.");
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/trusted-types/window-open.tentative.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="support/helper.sub.js"></script>
+<body>
+<script>
+ //helper functions for the tests
+ function testWindowOpen(t, url, win) {
+ let child_window = win.open(url, "", "");
+ child_window.onload = t.step_func_done(_ => {
+ assert_equals(child_window.location.href, "" + url);
+ child_window.close();
+ });
+ }
+
+ async_test(t => {
+ testWindowOpen(t, TrustedURL.create(URLS.safe), window);
+ }, "window.open: safe URL, safe construction.");
+
+ async_test(t => {
+ testWindowOpen(t, TrustedURL.unsafelyCreate(URLS.safe), window);
+ }, "window.open: safe URL, unsafe construction.");
+
+ async_test(t => {
+ testWindowOpen(t, TrustedURL.create(URLS.safe), document);
+ }, "document.open: safe URL, safe construction.");
+
+ async_test(t => {
+ testWindowOpen(t, TrustedURL.unsafelyCreate(URLS.safe), document);
+ }, "document.open: safe URL, unsafe construction.");
+</script>