Skip to content

Commit

Permalink
Import WPT tests for blocked modal dialogs in sanboxed documents
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=183568

Patch by Frederic Wang <fwang@igalia.com> on 2018-03-12
Reviewed by Youenn Fablet.

* resources/import-expectations.json:
* resources/resource-files.json:
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-1-expected.txt: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-1.html: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-2-expected.txt: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-2.html: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-3-expected.txt: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-3.html: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-4-expected.txt: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-4.html: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe-that-opens-modals.html: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_block_modals.js: Added.
(runTest):
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/w3c-import.log:
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/w3c-import.log:

Canonical link: https://commits.webkit.org/199229@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229535 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
fred-wang committed Mar 12, 2018
1 parent 58149fc commit 6bac87a
Show file tree
Hide file tree
Showing 15 changed files with 144 additions and 1 deletion.
23 changes: 23 additions & 0 deletions LayoutTests/imported/w3c/ChangeLog
@@ -1,3 +1,26 @@
2018-03-12 Frederic Wang <fwang@igalia.com>

Import WPT tests for blocked modal dialogs in sanboxed documents
https://bugs.webkit.org/show_bug.cgi?id=183568

Reviewed by Youenn Fablet.

* resources/import-expectations.json:
* resources/resource-files.json:
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-1-expected.txt: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-1.html: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-2-expected.txt: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-2.html: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-3-expected.txt: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-3.html: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-4-expected.txt: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-4.html: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe-that-opens-modals.html: Added.
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_block_modals.js: Added.
(runTest):
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/w3c-import.log:
* web-platform-tests/html/semantics/embedded-content/the-iframe-element/w3c-import.log:

2018-03-12 Antoine Quint <graouts@apple.com>

[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations
Expand Down
Expand Up @@ -339,4 +339,4 @@
"web-platform-tests/workers": "import",
"web-platform-tests/worklets": "skip",
"web-platform-tests/x-frame-options": "skip"
}
}
1 change: 1 addition & 0 deletions LayoutTests/imported/w3c/resources/resource-files.json
Expand Up @@ -525,6 +525,7 @@
"web-platform-tests/html/semantics/embedded-content/the-iframe-element/same_origin_child.html",
"web-platform-tests/html/semantics/embedded-content/the-iframe-element/same_origin_grandchild.html",
"web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/blank.htm",
"web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe-that-opens-modals.html",
"web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe-that-performs-top-navigation-on-popup.html",
"web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe-that-performs-top-navigation-without-user-gesture-failed.html",
"web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe-that-performs-top-navigation.html",
Expand Down
@@ -0,0 +1,5 @@
CONSOLE MESSAGE: line 6: Use of window.alert is not allowed in a sandboxed frame when the allow-modals flag is not set.


PASS Frames without `allow-modals` should not be able to open modal dialogs

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>iframe sandbox without allow_modals (alert)</title>
<link rel="author" title="Igalia" href="https://www.igalia.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-iframe-sandbox">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-iframe-element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe sandbox="allow-scripts"></iframe>
<script src="support/iframe_sandbox_block_modals.js"></script>
<script>
runTest("alert", undefined);
</script>
@@ -0,0 +1,5 @@
CONSOLE MESSAGE: line 9: Use of window.confirm is not allowed in a sandboxed frame when the allow-modals flag is not set.


PASS Frames without `allow-modals` should not be able to open modal dialogs

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>iframe sandbox without allow_modals (confirm)</title>
<link rel="author" title="Igalia" href="https://www.igalia.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-iframe-sandbox">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-iframe-element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe sandbox="allow-scripts"></iframe>
<script src="support/iframe_sandbox_block_modals.js"></script>
<script>
runTest("confirm", false);
</script>
@@ -0,0 +1,5 @@
CONSOLE MESSAGE: line 12: Use of window.prompt is not allowed in a sandboxed frame when the allow-modals flag is not set.


PASS Frames without `allow-modals` should not be able to open modal dialogs

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>iframe sandbox without allow_modals (prompt)</title>
<link rel="author" title="Igalia" href="https://www.igalia.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-iframe-sandbox">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-iframe-element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe sandbox="allow-scripts"></iframe>
<script src="support/iframe_sandbox_block_modals.js"></script>
<script>
runTest("prompt", null);
</script>
@@ -0,0 +1,5 @@
CONSOLE MESSAGE: line 15: Use of window.print is not allowed in a sandboxed frame when the allow-modals flag is not set.


PASS Frames without `allow-modals` should not be able to open modal dialogs

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>iframe sandbox without allow_modals (print)</title>
<link rel="author" title="Igalia" href="https://www.igalia.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-iframe-sandbox">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-iframe-element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe sandbox="allow-scripts"></iframe>
<script src="support/iframe_sandbox_block_modals.js"></script>
<script>
runTest("print", undefined);
</script>
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<script>
function openModal(name) {
switch (name) {
case "alert":
return alert("MESSAGE");
break;
case "confirm":
return confirm("MESSAGE?");
break;
case "prompt":
return prompt("MESSAGE:", "DEFAULT VALUE");
break;
case "print":
return print();
break;
}
}

onmessage = function(e) {
parent.postMessage(openModal(e.data), "*");
}
</script>
@@ -0,0 +1,18 @@
function runTest(modalName, expectedValue) {
let timeOutForFailingToOpenModal = 500;
let startTime;
async_test(t => {
let iframe = document.querySelector("iframe");
iframe.onload = t.step_func(() => {
window.addEventListener("message", t.step_func_done(e => {
// This tests work by checking the call to open the modal diaglog will return immediately (or at least within timeOutForFailingToOpenModal).
// If the modal dialog is not blocked, then it will wait for user input and the test will time out.
assert_less_than(new Date().getTime() - startTime, timeOutForFailingToOpenModal, "Call to open modal dialog did not return immediately");
assert_equals(e.data, expectedValue, "Call to open modal dialog did not return expected value");
}));
startTime = new Date().getTime();
iframe.contentWindow.postMessage(modalName, "*");
});
iframe.src = "support/iframe-that-opens-modals.html";
}, "Frames without `allow-modals` should not be able to open modal dialogs");
}
Expand Up @@ -15,6 +15,7 @@ None
------------------------------------------------------------------------
List of files:
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/blank.htm
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe-that-opens-modals.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe-that-performs-top-navigation-on-popup.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe-that-performs-top-navigation-without-user-gesture-failed.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe-that-performs-top-navigation.html
Expand Down Expand Up @@ -44,6 +45,7 @@ List of files:
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_029.htm
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_031.htm
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_032.htm
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_block_modals.js
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/navigation-changed-iframe.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/sandbox.pdf
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/support/sandbox_allow_script.html
Expand Down
Expand Up @@ -35,6 +35,10 @@ List of files:
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_allow_top_navigation-2.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_allow_top_navigation-3.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_allow_top_navigation_by_user_activation_without_user_gesture.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-1.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-2.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-3.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-4.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_navigate_ancestor-1.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_navigate_ancestor-2.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_navigate_descendants.html
Expand Down

0 comments on commit 6bac87a

Please sign in to comment.