Skip to content

Commit

Permalink
HTML: getSVGDocument() / contentDocument
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Nov 25, 2019
1 parent 0b9f39e commit f71c507
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
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");
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>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f71c507

Please sign in to comment.