function loadScript(path) { // "chrome://mochitests/content/browser/" corresponds to "TEST_HARNESS_FILES.testing.mochitest.browser.dom.quota.test.common" in moz.build, // and "_tests/testing/mochitest/browser/dom/quota/test/common" in the obj directory. const url = new URL(path, "chrome://mochitests/content/browser/");
Services.scriptloader.loadSubScript(url, this);
}
// These event (un)registration handlers only work for one window, DONOT use // them with multiple windows.
function registerPopupEventHandler(eventName, callback, win) { if (!win) {
win = window;
}
gActiveListeners[eventName] = function (event) { if (event.target != win.PopupNotifications.panel) { return;
}
win.PopupNotifications.panel.removeEventListener(
eventName,
gActiveListeners[eventName]
); delete gActiveListeners[eventName];
function unregisterAllPopupEventHandlers(win) { if (!win) {
win = window;
} for (let eventName in gActiveListeners) {
win.PopupNotifications.panel.removeEventListener(
eventName,
gActiveListeners[eventName]
);
}
gActiveListeners = {};
}
function triggerMainCommand(popup, win) { if (!win) {
win = window;
}
info("triggering main command");
let notifications = popup.childNodes;
ok(notifications.length, "at least one notification displayed");
let notification = notifications[0];
info("triggering command: " + notification.getAttribute("buttonlabel"));
function waitForMessage(aMessage, browser) { // We cannot capture aMessage inside the checkFn, so we override the // checkFn.toSource to tunnel aMessage instead.
let checkFn = function () {};
checkFn.toSource = function () { return `function checkFn(event) {
let message = ${aMessage.toSource()}; if (event.data == message) { returntrue;
} thrownew Error(
\`Unexpected result: \$\{event.data\}, expected \$\{message\}\`
);
}`;
};
return BrowserTestUtils.waitForContentEvent(
browser.selectedBrowser, "message", /* capture */ true,
checkFn, /* wantsUntrusted */ true
).then(() => { // An assertion in checkFn wouldn't be recorded as part of the test, so we // use this assertion to confirm that we've successfully received the // message (we'll only reach this point if that's the case).
ok(true, "Received message: " + aMessage);
});
}
function removePermission(url, permission) {
let uri = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService)
.newURI(url);
let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(
Ci.nsIScriptSecurityManager
);
let principal = ssm.createContentPrincipal(uri, {});
function getPermission(url, permission) {
let uri = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService)
.newURI(url);
let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(
Ci.nsIScriptSecurityManager
);
let principal = ssm.createContentPrincipal(uri, {});
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.