add_task(async function test_frame() {
let win = SpecialPowers.wrap(window);
info(`id=${win.browsingContext.id}`);
let [docURI, curURI] = await SpecialPowers.spawnChrome([win.browsingContext.id], async id => {
let bc = BrowsingContext.get(id);
return [
bc.currentWindowGlobal.documentURI.spec,
bc.currentURI.spec,
];
});
info(`docURI=${docURI}, curURI=${curURI}`);
is(window.location.href, curURI, "curURI has the expected value");
is(window.location.href, docURI, "documentURI has the expected value");
});
add_task(async function test_tls1_frame() {
let expframe = SpecialPowers.wrap(document.getElementById("tls1frame"));
let [docURI, curURI] = await SpecialPowers.spawnChrome(
[expframe.browsingContext.id], async id => {
const { TestUtils } = ChromeUtils.importESModule( "resource://testing-common/TestUtils.sys.mjs"
);
let bc = BrowsingContext.get(id);
// awkwardly wait for the current window global to update to the error page.
// would be nice to do just about anything else here...
await TestUtils.waitForCondition(
() =>
bc.currentURI && bc.currentURI.spec != "about:blank" &&
bc.currentWindowGlobal && bc.currentWindowGlobal.documentURI.spec != "about:blank", "waiting for current window global to be non-initial");
info(`currentWindowGlobal has updated in the parent!`);
return [
bc.currentWindowGlobal.documentURI.spec,
bc.currentURI.spec,
];
});
info(`docURI=${docURI}, curURI=${curURI}`);
is(curURI, "https://tls1.example.com/", "curURI has expected value");
ok(docURI.startsWith("about:neterror"), "documentURI starts with about:neterror");
});
let BROADCAST_ONLOAD_URL =
new URL("file_broadcast_currenturi_onload.html", location.href);
async function broadcastLoadTest(baseURI, callback) {
// Bug 1746646: Make mochitests work with TCP enabled (cookieBehavior = 5)
// Acquire storage access permission here so that the BroadcastChannel used to
// communicate with the opened windows works in xorigin tests. Otherwise,
// the iframe containing this page is isolated from first-party storage access,
// which isolates BroadcastChannel communication.
if (isXOrigin) {
await SpecialPowers.pushPrefEnv({
set: [["privacy.partition.always_partition_third_party_non_cookie_storage", false]],
});
SpecialPowers.wrap(document).notifyUserGestureActivation();
await SpecialPowers.addPermission( "storageAccessAPI",
true,
window.location.href
);
await SpecialPowers.wrap(document).requestStorageAccess();
}
let loaded = new Promise(resolve => {
let chan = new BroadcastChannel("test_broadcast_onload");
chan.onmessage = event => {
resolve(event.data);
};
});
let srcURL = new URL(BROADCAST_ONLOAD_URL.pathname, baseURI);
callback(srcURL.href);
let results = await loaded;
for (let { location, curURI, docURI } of results) {
info(`location=${location}, docURI=${docURI}, curURI=${curURI}`);
is(location, curURI, "curURI has expected value");
is(location, docURI, "documentURI has expected value");
}
}
async function normalFrameLoadTest(base) {
await broadcastLoadTest(base, src => {
let frame = document.createElement("iframe"); frame.src = src;
document.body.appendChild(frame);
});
}
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.