-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTML: getSVGDocument() / contentDocument
For whatwg/html#5094.
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
html/semantics/embedded-content/the-iframe-element/cross-origin-to-whom.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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 assertReason = `${name}[${api}]`; | ||
let possibleDocument = null; | ||
if (api == "getSVGDocument") { | ||
possibleDocument = instance[api](); | ||
} else { | ||
possibleDocument = instance[api]; | ||
} | ||
assert_not_equals(possibleDocument, null, `${name}[${api}]`); | ||
// This needs standardizing still | ||
// assert_class_string(possibleDocument, "XMLDocument"); | ||
|
||
// Ensure getSVGDocument() and contentDocument if both available return the same | ||
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; | ||
instances.forEach(instance => assert_apis(instance)); | ||
}); | ||
document.body.appendChild(frame); | ||
}, "Test embed/frame/iframe/object nested document APIs for same-origin and cross-origin"); |
10 changes: 10 additions & 0 deletions
10
html/semantics/embedded-content/the-iframe-element/support/document-with-embedded-svg.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.<script> | ||
["embed", "frame", "iframe", "object"].forEach(name => { | ||
const frame = document.body.appendChild(document.createElement(name)); | ||
let attr = "src"; | ||
if (name === "object") { | ||
attr = "data"; | ||
} | ||
frame[attr] = "svg.svg"; | ||
}); | ||
</script> |
1 change: 1 addition & 0 deletions
1
html/semantics/embedded-content/the-iframe-element/support/svg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.