summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/srcdoc-attribute-reset.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/srcdoc-attribute-reset.html')
-rw-r--r--testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/srcdoc-attribute-reset.html33
1 files changed, 33 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/srcdoc-attribute-reset.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/srcdoc-attribute-reset.html
new file mode 100644
index 0000000000..452a984afb
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/srcdoc-attribute-reset.html
@@ -0,0 +1,33 @@
+<title>Verify that clearing srcdoc resets the iframe's content.</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes">
+<link rel="author" title="James MacLean" href="mailto:wjmaclean@chromium.org">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<iframe id=myframe srcdoc='srcdoc_text'></iframe>
+<script>
+ 'use strict';
+
+ async_test(function(t) {
+ window.onload = () => {
+ // Verify that the srcdoc content is loaded before we start.
+ t.step(() => {
+ assert_true(typeof myframe.contentDocument !== 'undefined',
+ 'iframe has contentDocument');
+ assert_equals(myframe.contentDocument.body.innerText, 'srcdoc_text',
+ 'iframe contains srcdoc content');
+ });
+
+ myframe.onload = t.step_func_done(function() {
+ assert_true(typeof myframe.contentDocument !== 'undefined',
+ 'iframe has contentDocument');
+ assert_equals(myframe.contentDocument.body.innerText, '',
+ 'iframe content is empty');
+ });
+
+ // Don't remove srcdoc until the initial load has completed, and the
+ // frame's onload handler is in place.
+ myframe.removeAttribute('srcdoc');
+ };
+ }, 'Verify that the frame reloads with empty body after we remove srcdoc.');
+</script>