diff --git a/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-1.html b/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-1.html
index 8e936532d1aac7..ce171bfb8e10f9 100644
--- a/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-1.html
+++ b/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-1.html
@@ -1,5 +1,5 @@
-
+
iframe sandbox without allow_modals (alert)
@@ -7,23 +7,7 @@
+
diff --git a/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-2.html b/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-2.html
index 5fd47be01ac4ab..fbd4d23d015c88 100644
--- a/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-2.html
+++ b/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-2.html
@@ -1,5 +1,5 @@
-
+
iframe sandbox without allow_modals (confirm)
@@ -7,23 +7,7 @@
+
diff --git a/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-3.html b/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-3.html
index 992f4bafcad21f..57123011807589 100644
--- a/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-3.html
+++ b/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-3.html
@@ -1,5 +1,5 @@
-
+
iframe sandbox without allow_modals (prompt)
@@ -7,23 +7,7 @@
+
diff --git a/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-4.html b/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-4.html
index 8e1cbc4d76ea0e..f750e345ea338d 100644
--- a/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-4.html
+++ b/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_block_modals-4.html
@@ -1,5 +1,5 @@
-
+
iframe sandbox without allow_modals (print)
@@ -7,23 +7,7 @@
+
diff --git a/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_block_modals.js b/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_block_modals.js
new file mode 100644
index 00000000000000..50e0ca51d61c8e
--- /dev/null
+++ b/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_block_modals.js
@@ -0,0 +1,17 @@
+function runTest(modalName, expectedValue) {
+ let timeOutForFailingToOpenModal = 500;
+ let startTime;
+ async_test(t => {
+ let iframe = document.querySelector("iframe");
+ iframe.onload = function() {
+ window.addEventListener("message", t.step_func_done(e => {
+ e.source.close();
+ 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");
+}