mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 13:55:43 +00:00
Bug 1398619 - Correctly inherit backend for document created by DOMParser, and add test for it. r=bholley
The old code doesn't work because mScriptHandlingObject is a nsWeakPtr, which cannot be casted to nsPIDOMWindowInner directly. Since scriptHandlingObject is a strong reference to the same object, we can just try casting that. MozReview-Commit-ID: JRBs5N6xxc0 --HG-- extra : rebase_source : cd0237553198182b00ff9c667a17271b23464567
This commit is contained in:
parent
be5b995e78
commit
a0f7c55075
@ -463,7 +463,7 @@ DOMParser::SetUpDocument(DocumentFlavor aFlavor, nsIDOMDocument** aResult)
|
||||
|
||||
// Try to inherit a style backend.
|
||||
auto styleBackend = StyleBackendType::None;
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(mScriptHandlingObject);
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(scriptHandlingObject);
|
||||
if (window && window->GetExtantDoc()) {
|
||||
styleBackend = window->GetExtantDoc()->GetStyleBackendType();
|
||||
}
|
||||
|
@ -174,6 +174,7 @@ skip-if = !stylo # This is a stylo test; gecko isn't deterministic here
|
||||
skip-if = toolkit == 'android'
|
||||
[test_computed_style.html]
|
||||
[test_computed_style_bfcache_display_none.html]
|
||||
[test_computed_style_in_created_document.html]
|
||||
[test_computed_style_min_size_auto.html]
|
||||
[test_computed_style_no_pseudo.html]
|
||||
[test_computed_style_prefs.html]
|
||||
|
@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for bug 1398619</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
let referenceFontSize = getComputedStyle(document.body).fontSize;
|
||||
|
||||
function checkComputedStyle(desc, doc) {
|
||||
try {
|
||||
let fontSize = getComputedStyle(doc.body).fontSize;
|
||||
is(fontSize, referenceFontSize, `${desc}: get computed font-size`);
|
||||
} catch (e) {
|
||||
ok(false, `${desc}: fail to get computed font-size, ${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function runTest() {
|
||||
// DOMParser
|
||||
{
|
||||
let parser = new DOMParser();
|
||||
let doc = parser.parseFromString("<body>", "text/html");
|
||||
checkComputedStyle("DOMParser", doc);
|
||||
}
|
||||
// DOMImplementation
|
||||
{
|
||||
let doc = document.implementation.createHTMLDocument("");
|
||||
checkComputedStyle("DOMImplementation", doc);
|
||||
}
|
||||
// XMLHttpRequest
|
||||
{
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "empty.html");
|
||||
xhr.responseType = "document";
|
||||
let promise = new Promise(resolve => {
|
||||
xhr.onload = resolve;
|
||||
});
|
||||
xhr.send();
|
||||
await promise;
|
||||
checkComputedStyle("XMLHttpRequest", xhr.responseXML);
|
||||
}
|
||||
}
|
||||
runTest()
|
||||
.catch(e => ok(false, `Exception: ${e}`))
|
||||
.then(() => SimpleTest.finish());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user