diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/cross-origin-to-whom-part-2.window.js b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/cross-origin-to-whom-part-2.window.js new file mode 100644 index 0000000000000..5ff43a63f9423 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/cross-origin-to-whom-part-2.window.js @@ -0,0 +1,59 @@ +async_test(t => { + const frame = document.body.appendChild(document.createElement("iframe")); + frame.src = "support/document-with-embedded-svg.html"; + const elements = { + "embed": ["getSVGDocument"], + "frame": ["contentDocument"], + "iframe": ["getSVGDocument", "contentDocument"], + "object": ["getSVGDocument", "contentDocument"] + }; + function element_to_document(element, api) { + return api === "getSVGDocument" ? element[api]() : element[api]; + } + function assert_apis(instance, assertNull = false) { + const name = instance.localName; + let priorPossibleDocument = null; + elements[name].forEach(api => { + const assertReason = `${name}.${api}`; + const possibleDocument = element_to_document(instance, api); + if (assertNull) { + assert_equals(possibleDocument, null, assertReason); + return; + } else { + assert_not_equals(possibleDocument, null, assertReason); + + + + } + + + if (priorPossibleDocument === null) { + priorPossibleDocument = possibleDocument; + } else { + assert_equals(priorPossibleDocument, possibleDocument); + } + }); + } + frame.onload = t.step_func_done(() => { + const instances = Object.keys(elements).map(element => frame.contentDocument.querySelector(element)); + + instances.forEach(instance => assert_apis(instance)); + + + instances.forEach(instance => { + const svgDocument = element_to_document(instance, elements[instance.localName][0]); + svgDocument.domain = svgDocument.domain; + }); + instances.forEach(instance => assert_apis(instance, true)); + const svgContainer = frame.contentDocument; + + + document.domain = document.domain; + assert_equals(frame.contentDocument, null); + instances.forEach(instance => assert_apis(instance, true)); + + svgContainer.domain = svgContainer.domain; + instances.forEach(instance => assert_apis(instance)); + }); + document.body.appendChild(frame); +}, "Test embed/frame/iframe/object nested document APIs for same origin-domain and cross origin-domain embedder document"); diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/cross-origin-to-whom.window.js b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/cross-origin-to-whom.window.js new file mode 100644 index 0000000000000..83e8254ddd187 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/cross-origin-to-whom.window.js @@ -0,0 +1,37 @@ +async_test(t => { + const frame = document.body.appendChild(document.createElement("iframe")); + frame.src = "support/document-with-embedded-svg.html"; + const elements = { + "embed": ["getSVGDocument"], + "frame": ["contentDocument"], + "iframe": ["getSVGDocument", "contentDocument"], + "object": ["getSVGDocument", "contentDocument"] + }; + function assert_apis(instance) { + const name = instance.localName; + let priorPossibleDocument = null; + elements[name].forEach(api => { + const possibleDocument = api == "getSVGDocument" ? instance[api]() : instance[api]; + assert_not_equals(possibleDocument, null, `${name}.${api}`); + + + + + if (priorPossibleDocument === null) { + priorPossibleDocument = possibleDocument; + } else { + assert_equals(priorPossibleDocument, possibleDocument); + } + }); + } + frame.onload = t.step_func_done(() => { + const instances = Object.keys(elements).map(element => frame.contentDocument.querySelector(element)); + + instances.forEach(instance => assert_apis(instance)); + + document.domain = document.domain; + assert_equals(frame.contentDocument, null); + instances.forEach(instance => assert_apis(instance)); + }); + document.body.appendChild(frame); +}, "Test embed/frame/iframe/object nested document APIs for same origin-domain and cross origin-domain current settings object"); diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/document-with-embedded-svg.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/document-with-embedded-svg.html new file mode 100644 index 0000000000000..a81d13d9a8b63 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/document-with-embedded-svg.html @@ -0,0 +1,9 @@ + + + diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/svg.svg b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/svg.svg new file mode 100644 index 0000000000000..1570afcadc238 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/svg.svg @@ -0,0 +1 @@ +