blob: 67733d8101b94e788f670393f624b35b7a9c7876 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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");
}
|