diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /browser/extensions/pdfjs/test | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/extensions/pdfjs/test')
-rw-r--r-- | browser/extensions/pdfjs/test/.eslintrc.js | 7 | ||||
-rw-r--r-- | browser/extensions/pdfjs/test/browser.ini | 10 | ||||
-rw-r--r-- | browser/extensions/pdfjs/test/browser_pdfjs_main.js | 67 | ||||
-rw-r--r-- | browser/extensions/pdfjs/test/browser_pdfjs_navigation.js | 283 | ||||
-rw-r--r-- | browser/extensions/pdfjs/test/browser_pdfjs_savedialog.js | 65 | ||||
-rw-r--r-- | browser/extensions/pdfjs/test/browser_pdfjs_views.js | 67 | ||||
-rw-r--r-- | browser/extensions/pdfjs/test/browser_pdfjs_zoom.js | 154 | ||||
-rw-r--r-- | browser/extensions/pdfjs/test/file_pdfjs_test.pdf | bin | 0 -> 150611 bytes | |||
-rw-r--r-- | browser/extensions/pdfjs/test/head.js | 15 |
9 files changed, 668 insertions, 0 deletions
diff --git a/browser/extensions/pdfjs/test/.eslintrc.js b/browser/extensions/pdfjs/test/.eslintrc.js new file mode 100644 index 000000000..c764b133d --- /dev/null +++ b/browser/extensions/pdfjs/test/.eslintrc.js @@ -0,0 +1,7 @@ +"use strict"; + +module.exports = { + "extends": [ + "../../../../testing/mochitest/browser.eslintrc.js" + ] +}; diff --git a/browser/extensions/pdfjs/test/browser.ini b/browser/extensions/pdfjs/test/browser.ini new file mode 100644 index 000000000..fb4aa9afc --- /dev/null +++ b/browser/extensions/pdfjs/test/browser.ini @@ -0,0 +1,10 @@ +[DEFAULT] +support-files = + file_pdfjs_test.pdf + head.js + +[browser_pdfjs_main.js] +[browser_pdfjs_navigation.js] +[browser_pdfjs_savedialog.js] +[browser_pdfjs_views.js] +[browser_pdfjs_zoom.js] diff --git a/browser/extensions/pdfjs/test/browser_pdfjs_main.js b/browser/extensions/pdfjs/test/browser_pdfjs_main.js new file mode 100644 index 000000000..9660e92c1 --- /dev/null +++ b/browser/extensions/pdfjs/test/browser_pdfjs_main.js @@ -0,0 +1,67 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +const RELATIVE_DIR = "browser/extensions/pdfjs/test/"; +const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR; + +add_task(function* test() { + let handlerService = Cc["@mozilla.org/uriloader/handler-service;1"].getService(Ci.nsIHandlerService); + let mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService); + let handlerInfo = mimeService.getFromTypeAndExtension('application/pdf', 'pdf'); + + // Make sure pdf.js is the default handler. + is(handlerInfo.alwaysAskBeforeHandling, false, 'pdf handler defaults to always-ask is false'); + is(handlerInfo.preferredAction, Ci.nsIHandlerInfo.handleInternally, 'pdf handler defaults to internal'); + + info('Pref action: ' + handlerInfo.preferredAction); + + yield BrowserTestUtils.withNewTab({ gBrowser: gBrowser, url: "about:blank" }, + function* (newTabBrowser) { + yield waitForPdfJS(newTabBrowser, TESTROOT + "file_pdfjs_test.pdf"); + + ok(gBrowser.isFindBarInitialized(), "Browser FindBar initialized!"); + + yield ContentTask.spawn(newTabBrowser, null, function* () { + // + // Overall sanity tests + // + Assert.ok(content.document.querySelector('div#viewer'), "document content has viewer UI"); + Assert.ok('PDFJS' in content.wrappedJSObject, "window content has PDFJS object"); + + // + // Sidebar: open + // + var sidebar = content.document.querySelector('button#sidebarToggle'), + outerContainer = content.document.querySelector('div#outerContainer'); + + sidebar.click(); + Assert.ok(outerContainer.classList.contains('sidebarOpen'), "sidebar opens on click"); + + // + // Sidebar: close + // + sidebar.click(); + Assert.ok(!outerContainer.classList.contains('sidebarOpen'), "sidebar closes on click"); + + // + // Page change from prev/next buttons + // + var prevPage = content.document.querySelector('button#previous'), + nextPage = content.document.querySelector('button#next'); + + var pgNumber = content.document.querySelector('input#pageNumber').value; + Assert.equal(parseInt(pgNumber, 10), 1, "initial page is 1"); + + // + // Bookmark button + // + var viewBookmark = content.document.querySelector('a#viewBookmark'); + viewBookmark.click(); + + Assert.ok(viewBookmark.href.length > 0, "viewBookmark button has href"); + + var viewer = content.wrappedJSObject.PDFViewerApplication; + yield viewer.close(); + }); + }); +}); diff --git a/browser/extensions/pdfjs/test/browser_pdfjs_navigation.js b/browser/extensions/pdfjs/test/browser_pdfjs_navigation.js new file mode 100644 index 000000000..b01a87ec8 --- /dev/null +++ b/browser/extensions/pdfjs/test/browser_pdfjs_navigation.js @@ -0,0 +1,283 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +requestLongerTimeout(2); + +Components.utils.import("resource://gre/modules/Promise.jsm", this); + +const RELATIVE_DIR = "browser/extensions/pdfjs/test/"; +const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR; + +const PDF_OUTLINE_ITEMS = 17; +const TESTS = [ + { + action: { + selector: "button#next", + event: "click" + }, + expectedPage: 2, + message: "navigated to next page using NEXT button" + + }, + { + action: { + selector: "button#previous", + event: "click" + }, + expectedPage: 1, + message: "navigated to previous page using PREV button" + }, + { + action: { + selector: "button#next", + event: "click" + }, + expectedPage: 2, + message: "navigated to next page using NEXT button" + }, + { + action: { + selector: "input#pageNumber", + value: 1, + event: "change" + }, + expectedPage: 1, + message: "navigated to first page using pagenumber" + }, + { + action: { + selector: "#thumbnailView a:nth-child(4)", + event: "click" + }, + expectedPage: 4, + message: "navigated to 4th page using thumbnail view" + }, + { + action: { + selector: "#thumbnailView a:nth-child(2)", + event: "click" + }, + expectedPage: 2, + message: "navigated to 2nd page using thumbnail view" + }, + { + action: { + selector: "#viewer", + event: "keydown", + keyCode: 36 + }, + expectedPage: 1, + message: "navigated to 1st page using 'home' key" + }, + { + action: { + selector: "#viewer", + event: "keydown", + keyCode: 34 + }, + expectedPage: 2, + message: "navigated to 2nd page using 'Page Down' key" + }, + { + action: { + selector: "#viewer", + event: "keydown", + keyCode: 33 + }, + expectedPage: 1, + message: "navigated to 1st page using 'Page Up' key" + }, + { + action: { + selector: "#viewer", + event: "keydown", + keyCode: 39 + }, + expectedPage: 2, + message: "navigated to 2nd page using 'right' key" + }, + { + action: { + selector: "#viewer", + event: "keydown", + keyCode: 37 + }, + expectedPage: 1, + message: "navigated to 1st page using 'left' key" + }, + { + action: { + selector: "#viewer", + event: "keydown", + keyCode: 35 + }, + expectedPage: 5, + message: "navigated to last page using 'home' key" + }, + { + action: { + selector: ".outlineItem:nth-child(1) a", + event: "click" + }, + expectedPage: 1, + message: "navigated to 1st page using outline view" + }, + { + action: { + selector: ".outlineItem:nth-child(" + PDF_OUTLINE_ITEMS + ") a", + event: "click" + }, + expectedPage: 4, + message: "navigated to 4th page using outline view" + }, + { + action: { + selector: "input#pageNumber", + value: 5, + event: "change" + }, + expectedPage: 5, + message: "navigated to 5th page using pagenumber" + } +]; + +add_task(function* test() { + let mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService); + let handlerInfo = mimeService.getFromTypeAndExtension('application/pdf', 'pdf'); + + // Make sure pdf.js is the default handler. + is(handlerInfo.alwaysAskBeforeHandling, false, 'pdf handler defaults to always-ask is false'); + is(handlerInfo.preferredAction, Ci.nsIHandlerInfo.handleInternally, 'pdf handler defaults to internal'); + + info('Pref action: ' + handlerInfo.preferredAction); + + yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, + function* (newTabBrowser) { + yield waitForPdfJS(newTabBrowser, TESTROOT + "file_pdfjs_test.pdf"); + + yield ContentTask.spawn(newTabBrowser, null, function* () { + // Check if PDF is opened with internal viewer + Assert.ok(content.document.querySelector("div#viewer"), "document content has viewer UI"); + Assert.ok("PDFJS" in content.wrappedJSObject, "window content has PDFJS object"); + }); + + yield ContentTask.spawn(newTabBrowser, null, contentSetUp); + + yield Task.spawn(runTests(newTabBrowser)); + + yield ContentTask.spawn(newTabBrowser, null, function*() { + let pageNumber = content.document.querySelector('input#pageNumber'); + Assert.equal(pageNumber.value, pageNumber.max, "Document is left on the last page"); + }); + }); +}); + +function* contentSetUp() { + /** + * Outline Items gets appended to the document later on we have to + * wait for them before we start to navigate though document + * + * @param document + * @returns {deferred.promise|*} + */ + function waitForOutlineItems(document) { + return new Promise((resolve, reject) => { + document.addEventListener("outlineloaded", function outlineLoaded(evt) { + document.removeEventListener("outlineloaded", outlineLoaded); + var outlineCount = evt.detail.outlineCount; + + if (document.querySelectorAll(".outlineItem").length === outlineCount) { + resolve(); + } else { + reject(); + } + }); + }); + } + + /** + * The key navigation has to happen in page-fit, otherwise it won't scroll + * through a complete page + * + * @param document + * @returns {deferred.promise|*} + */ + function setZoomToPageFit(document) { + return new Promise((resolve) => { + document.addEventListener("pagerendered", function onZoom(e) { + document.removeEventListener("pagerendered", onZoom); + document.querySelector("#viewer").click(); + resolve(); + }); + + var select = document.querySelector("select#scaleSelect"); + select.selectedIndex = 2; + select.dispatchEvent(new Event("change")); + }); + } + + yield waitForOutlineItems(content.document); + yield setZoomToPageFit(content.document); +} + +/** + * As the page changes asynchronously, we have to wait for the event after + * we trigger the action so we will be at the expected page number after each action + * + * @param document + * @param window + * @param test + * @param callback + */ +function* runTests(browser) { + yield ContentTask.spawn(browser, TESTS, function* (TESTS) { + let window = content; + let document = window.document; + + for (let test of TESTS) { + let deferred = {}; + deferred.promise = new Promise((resolve, reject) => { + deferred.resolve = resolve; + deferred.reject = reject; + }); + + let pageNumber = document.querySelector('input#pageNumber'); + + // 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() { + if (pageNumber.value == test.expectedPage) { + window.removeEventListener('pagechange', pageChange); + window.clearTimeout(timeout); + deferred.resolve(+pageNumber.value); + } + }); + + // Get the element and trigger the action for changing the page + var el = document.querySelector(test.action.selector); + Assert.ok(el, "Element '" + test.action.selector + "' has been found"); + + // The value option is for input case + if (test.action.value) + el.value = test.action.value; + + // Dispatch the event for changing the page + if (test.action.event == "keydown") { + var ev = document.createEvent("KeyboardEvent"); + ev.initKeyEvent("keydown", true, true, null, false, false, false, false, + test.action.keyCode, 0); + el.dispatchEvent(ev); + } + else { + var ev = new Event(test.action.event); + } + el.dispatchEvent(ev); + + let pgNumber = yield deferred.promise; + Assert.equal(pgNumber, test.expectedPage, test.message); + } + + var viewer = content.wrappedJSObject.PDFViewerApplication; + yield viewer.close(); + }); +} diff --git a/browser/extensions/pdfjs/test/browser_pdfjs_savedialog.js b/browser/extensions/pdfjs/test/browser_pdfjs_savedialog.js new file mode 100644 index 000000000..a6564e591 --- /dev/null +++ b/browser/extensions/pdfjs/test/browser_pdfjs_savedialog.js @@ -0,0 +1,65 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +const RELATIVE_DIR = "browser/extensions/pdfjs/test/"; +const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR; + +function test() { + var oldAction = changeMimeHandler(Ci.nsIHandlerInfo.useSystemDefault, true); + var tab = gBrowser.addTab(TESTROOT + "file_pdfjs_test.pdf"); + // + // Test: "Open with" dialog comes up when pdf.js is not selected as the default + // handler. + // + addWindowListener('chrome://mozapps/content/downloads/unknownContentType.xul', finish); + + waitForExplicitFinish(); + registerCleanupFunction(function() { + changeMimeHandler(oldAction[0], oldAction[1]); + gBrowser.removeTab(tab); + }); +} + +function changeMimeHandler(preferredAction, alwaysAskBeforeHandling) { + let handlerService = Cc["@mozilla.org/uriloader/handler-service;1"].getService(Ci.nsIHandlerService); + let mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService); + let handlerInfo = mimeService.getFromTypeAndExtension('application/pdf', 'pdf'); + var oldAction = [handlerInfo.preferredAction, handlerInfo.alwaysAskBeforeHandling]; + + // Change and save mime handler settings + handlerInfo.alwaysAskBeforeHandling = alwaysAskBeforeHandling; + handlerInfo.preferredAction = preferredAction; + handlerService.store(handlerInfo); + + Services.obs.notifyObservers(null, 'pdfjs:handlerChanged', null); + + // Refresh data + handlerInfo = mimeService.getFromTypeAndExtension('application/pdf', 'pdf'); + + // + // Test: Mime handler was updated + // + is(handlerInfo.alwaysAskBeforeHandling, alwaysAskBeforeHandling, 'always-ask prompt change successful'); + is(handlerInfo.preferredAction, preferredAction, 'mime handler change successful'); + + return oldAction; +} + +function addWindowListener(aURL, aCallback) { + Services.wm.addListener({ + onOpenWindow: function(aXULWindow) { + info("window opened, waiting for focus"); + Services.wm.removeListener(this); + + var domwindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindow); + waitForFocus(function() { + is(domwindow.document.location.href, aURL, "should have seen the right window open"); + domwindow.close(); + aCallback(); + }, domwindow); + }, + onCloseWindow: function(aXULWindow) { }, + onWindowTitleChange: function(aXULWindow, aNewTitle) { } + }); +} diff --git a/browser/extensions/pdfjs/test/browser_pdfjs_views.js b/browser/extensions/pdfjs/test/browser_pdfjs_views.js new file mode 100644 index 000000000..d14503e41 --- /dev/null +++ b/browser/extensions/pdfjs/test/browser_pdfjs_views.js @@ -0,0 +1,67 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +const RELATIVE_DIR = "browser/extensions/pdfjs/test/"; +const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR; + +add_task(function* test() { + let handlerService = Cc["@mozilla.org/uriloader/handler-service;1"].getService(Ci.nsIHandlerService); + let mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService); + let handlerInfo = mimeService.getFromTypeAndExtension('application/pdf', 'pdf'); + + // Make sure pdf.js is the default handler. + is(handlerInfo.alwaysAskBeforeHandling, false, 'pdf handler defaults to always-ask is false'); + is(handlerInfo.preferredAction, Ci.nsIHandlerInfo.handleInternally, 'pdf handler defaults to internal'); + + info('Pref action: ' + handlerInfo.preferredAction); + + yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, + function* (browser) { + // check that PDF is opened with internal viewer + yield waitForPdfJS(browser, TESTROOT + "file_pdfjs_test.pdf"); + + yield ContentTask.spawn(browser, null, function* () { + Assert.ok(content.document.querySelector("div#viewer"), "document content has viewer UI"); + Assert.ok("PDFJS" in content.wrappedJSObject, "window content has PDFJS object"); + + //open sidebar + var sidebar = content.document.querySelector('button#sidebarToggle'); + var outerContainer = content.document.querySelector('div#outerContainer'); + + sidebar.click(); + Assert.ok(outerContainer.classList.contains("sidebarOpen"), "sidebar opens on click"); + + // check that thumbnail view is open + var thumbnailView = content.document.querySelector('div#thumbnailView'); + var outlineView = content.document.querySelector('div#outlineView'); + + Assert.equal(thumbnailView.getAttribute("class"), null, + "Initial view is thumbnail view"); + Assert.equal(outlineView.getAttribute("class"), "hidden", + "Outline view is hidden initially"); + + //switch to outline view + var viewOutlineButton = content.document.querySelector('button#viewOutline'); + viewOutlineButton.click(); + + Assert.equal(thumbnailView.getAttribute("class"), "hidden", + "Thumbnail view is hidden when outline is selected"); + Assert.equal(outlineView.getAttribute("class"), "", + "Outline view is visible when selected"); + + //switch back to thumbnail view + var viewThumbnailButton = content.document.querySelector('button#viewThumbnail'); + viewThumbnailButton.click(); + + Assert.equal(thumbnailView.getAttribute("class"), "", + "Thumbnail view is visible when selected"); + Assert.equal(outlineView.getAttribute("class"), "hidden", + "Outline view is hidden when thumbnail is selected"); + + sidebar.click(); + + var viewer = content.wrappedJSObject.PDFViewerApplication; + yield viewer.close(); + }); + }); +}); diff --git a/browser/extensions/pdfjs/test/browser_pdfjs_zoom.js b/browser/extensions/pdfjs/test/browser_pdfjs_zoom.js new file mode 100644 index 000000000..f2b73fd99 --- /dev/null +++ b/browser/extensions/pdfjs/test/browser_pdfjs_zoom.js @@ -0,0 +1,154 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +requestLongerTimeout(2); + +Components.utils.import("resource://gre/modules/Promise.jsm", this); + +const RELATIVE_DIR = "browser/extensions/pdfjs/test/"; +const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR; + +const TESTS = [ + { + action: { + selector: "button#zoomIn", + event: "click" + }, + expectedZoom: 1, // 1 - zoom in + message: "Zoomed in using the '+' (zoom in) button" + }, + + { + action: { + selector: "button#zoomOut", + event: "click" + }, + expectedZoom: -1, // -1 - zoom out + message: "Zoomed out using the '-' (zoom out) button" + }, + + { + action: { + keyboard: true, + keyCode: 61, + event: "+" + }, + expectedZoom: 1, // 1 - zoom in + message: "Zoomed in using the CTRL++ keys" + }, + + { + action: { + keyboard: true, + keyCode: 109, + event: "-" + }, + expectedZoom: -1, // -1 - zoom out + message: "Zoomed out using the CTRL+- keys" + }, + + { + action: { + selector: "select#scaleSelect", + index: 5, + event: "change" + }, + expectedZoom: -1, // -1 - zoom out + message: "Zoomed using the zoom picker" + } +]; + +add_task(function* test() { + let handlerService = Cc["@mozilla.org/uriloader/handler-service;1"] + .getService(Ci.nsIHandlerService); + let mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService); + let handlerInfo = mimeService.getFromTypeAndExtension('application/pdf', 'pdf'); + + // Make sure pdf.js is the default handler. + is(handlerInfo.alwaysAskBeforeHandling, false, + 'pdf handler defaults to always-ask is false'); + is(handlerInfo.preferredAction, Ci.nsIHandlerInfo.handleInternally, + 'pdf handler defaults to internal'); + + info('Pref action: ' + handlerInfo.preferredAction); + + yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, + function* (newTabBrowser) { + yield waitForPdfJS(newTabBrowser, TESTROOT + "file_pdfjs_test.pdf" + "#zoom=100"); + + yield ContentTask.spawn(newTabBrowser, TESTS, function* (TESTS) { + let document = content.document; + + function waitForRender() { + return new Promise((resolve) => { + document.addEventListener("pagerendered", function onPageRendered(e) { + if(e.detail.pageNumber !== 1) { + return; + } + + document.removeEventListener("pagerendered", onPageRendered, true); + resolve(); + }, true); + }); + } + + // check that PDF is opened with internal viewer + Assert.ok(content.document.querySelector("div#viewer"), "document content has viewer UI"); + Assert.ok("PDFJS" in content.wrappedJSObject, "window content has PDFJS object"); + + let initialWidth, previousWidth; + initialWidth = previousWidth = + parseInt(content.document.querySelector("div#pageContainer1").style.width); + + for (let test of TESTS) { + // We zoom using an UI element + var ev; + if (test.action.selector) { + // Get the element and trigger the action for changing the zoom + var el = document.querySelector(test.action.selector); + Assert.ok(el, "Element '" + test.action.selector + "' has been found"); + + if (test.action.index){ + el.selectedIndex = test.action.index; + } + + // Dispatch the event for changing the zoom + ev = new Event(test.action.event); + } + // We zoom using keyboard + else { + // Simulate key press + ev = new content.KeyboardEvent("keydown", + { key: test.action.event, + keyCode: test.action.keyCode, + ctrlKey: true }); + el = content; + } + + el.dispatchEvent(ev); + yield waitForRender(); + + var pageZoomScale = content.document.querySelector('select#scaleSelect'); + + // The zoom value displayed in the zoom select + var zoomValue = pageZoomScale.options[pageZoomScale.selectedIndex].innerHTML; + + let pageContainer = content.document.querySelector('div#pageContainer1'); + let actualWidth = parseInt(pageContainer.style.width); + + // the actual zoom of the PDF document + let computedZoomValue = parseInt(((actualWidth/initialWidth).toFixed(2))*100) + "%"; + Assert.equal(computedZoomValue, zoomValue, "Content has correct zoom"); + + // Check that document zooms in the expected way (in/out) + let zoom = (actualWidth - previousWidth) * test.expectedZoom; + Assert.ok(zoom > 0, test.message); + + previousWidth = actualWidth; + } + + var viewer = content.wrappedJSObject.PDFViewerApplication; + yield viewer.close(); + }); + }); +}); diff --git a/browser/extensions/pdfjs/test/file_pdfjs_test.pdf b/browser/extensions/pdfjs/test/file_pdfjs_test.pdf Binary files differnew file mode 100644 index 000000000..7ad87e3c2 --- /dev/null +++ b/browser/extensions/pdfjs/test/file_pdfjs_test.pdf diff --git a/browser/extensions/pdfjs/test/head.js b/browser/extensions/pdfjs/test/head.js new file mode 100644 index 000000000..d980bceb1 --- /dev/null +++ b/browser/extensions/pdfjs/test/head.js @@ -0,0 +1,15 @@ +function waitForPdfJS(browser, url) { + // Runs tests after all 'load' event handlers have fired off + return ContentTask.spawn(browser, url, function* (url) { + yield 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); + resolve(); + }, false, true); + + content.location = url; + }); + }); +} |