gecko-dev/browser/extensions/pdfjs/test/head.js
Jonas Jenwald 7274d76300 Bug 1492849 - Update the PDF viewer mochitests to utilize the, recently implemented, general re-dispatching of internal events to the DOM. r=bdahl
By updating the PDF viewer mochitests to instead use the new support for re-dispatching general `EventBus` events to the DOM, as implemented in https://github.com/mozilla/pdf.js/pull/10019, this will allow (future) removal of the hard-coded DOM event dispatching currently present in the https://github.com/mozilla/pdf.js/blob/master/web/dom_events.js file.
2018-09-20 15:43:54 +02:00

20 lines
658 B
JavaScript

async function waitForPdfJS(browser, url) {
await SpecialPowers.pushPrefEnv({
set: [
["pdfjs.eventBusDispatchToDOM", true],
],
});
// Runs tests after all "load" event handlers have fired off
return ContentTask.spawn(browser, url, async function(contentUrl) {
await new Promise((resolve) => {
// NB: Add the listener to the global object so that we receive the
// event fired from the new window.
addEventListener("documentloaded", function listener() {
removeEventListener("documentloaded", listener, false);
resolve();
}, false, true);
content.location = contentUrl;
});
});
}