/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// Regression test for bug 2034329. // // DOMStringList::GetParentObject() used to return nullptr. // This would cause DOMStringList to be created in the current global's realm, // which is problematic if this is an extension script's global realm as this will // cause subsequent accesses by web content to throw security errors.
add_task(async function bug2034329_domstringlist_realm() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
content_scripts: [
{
matches: ["http://mochi.test/*"],
js: ["content.js"],
run_at: "document_start",
},
],
},
files: { "content.js": function () { // Read ancestorOrigins from the extension content script first. // Before fix for bug2034329 DOMStringList would be created in the callers compartment. // Any subsequent accesses by web content would throw exceptions. void location.ancestorOrigins; // eslint-disable-line no-unused-expressions
},
},
});
await extension.startup();
await BrowserTestUtils.withNewTab(TEST_PAGE, async function (browser) {
let result = await SpecialPowers.spawn(browser, [], function () {
return content.document.getElementById("result").textContent;
});
ok(
result.startsWith("ok:"), "location.ancestorOrigins must be readable from the page script after " + "an extension content script accessed it first (got: " +
result + ")"
);
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.