Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/embedded-content/the-iframe-element/srcdoc-attribute-reset.html - WPT Dashboard Interop Dashboard
<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>