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.
This commit is contained in:
Jonas Jenwald 2018-09-20 15:43:54 +02:00
Родитель 8515ea9f42
Коммит 7274d76300
2 изменённых файлов: 10 добавлений и 5 удалений

Просмотреть файл

@ -242,9 +242,9 @@ async function runTests(browser) {
// Add an event-listener to wait for page to change, afterwards resolve the promise
let timeout = window.setTimeout(() => deferred.reject(), 5000);
window.addEventListener("pagechange", function pageChange() {
window.addEventListener("pagechanging", function pageChange() {
if (pageNumber.value == test.expectedPage) {
window.removeEventListener("pagechange", pageChange);
window.removeEventListener("pagechanging", pageChange);
window.clearTimeout(timeout);
deferred.resolve(+pageNumber.value);
}

Просмотреть файл

@ -1,11 +1,16 @@
function waitForPdfJS(browser, url) {
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("documentload", function listener() {
removeEventListener("documentload", listener, false);
addEventListener("documentloaded", function listener() {
removeEventListener("documentloaded", listener, false);
resolve();
}, false, true);