// Some existing mochitests expect the mock to click the notification. // The state here is specific to each caller as register() uses // SpecialPowers.loadChromeScript that ensures evaluating on each call // without caching objects.
autoClick: false,
};
function clickNotifications(doClose) { // Until we need to close a specific notification, just click them all. for (let [name, notification] of Object.entries(activeNotifications)) {
let { listener, cookie } = notification;
listener.observe(null, "alertclickcallback", cookie); if (doClose) {
mockAlertsService.closeAlert(name);
}
}
}
function closeAllNotifications() { for (let alertName of Object.keys(activeNotifications)) {
mockAlertsService.closeAlert(alertName);
}
}
addMessageListener("mock-alert-service:get-icon-image", id => {
let image = activeNotifications[id].image; if (!image) { returnnull;
}
const imgTools = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools);
let stream = imgTools.encodeImage(image, "image/png");
let binaryStream = new BinaryInputStream(stream);
let count = stream.available();
let arrayBuffer = new ArrayBuffer(count);
let actuallyRead = binaryStream.readArrayBuffer(count, arrayBuffer); if (actuallyRead != count) { throw Error("Did not read whole stream");
}
return arrayBuffer;
});
addMessageListener("mock-alert-service:set-history", value => {
history = value;
});
addMessageListener("mock-alert-service:set-throw-history", value => {
throwHistory = value;
});
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.