зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
8515ea9f42
Коммит
7274d76300
|
@ -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);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче