Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import WPT tests for blocked modal dialogs in sanboxed documents
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
Showing
15 changed files
with
144 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
.../semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-1-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
13 changes: 13 additions & 0 deletions
13
...sts/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-1.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
5 changes: 5 additions & 0 deletions
5
.../semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-2-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
13 changes: 13 additions & 0 deletions
13
...sts/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-2.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
5 changes: 5 additions & 0 deletions
5
.../semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-3-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
13 changes: 13 additions & 0 deletions
13
...sts/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-3.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
5 changes: 5 additions & 0 deletions
5
.../semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-4-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
13 changes: 13 additions & 0 deletions
13
...sts/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-4.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
23 changes: 23 additions & 0 deletions
23
.../html/semantics/embedded-content/the-iframe-element/support/iframe-that-opens-modals.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
18 changes: 18 additions & 0 deletions
18
...html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_block_modals.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters