Back out 5 changesets (bug 1159385, bug 1165558) for making browser_pdfjs_zoom.js frequently leak on Windows

CLOSED TREE

Backed out changeset 9c0a6b934c7a (bug 1159385)
Backed out changeset 1dcf1d5a95ce (bug 1159385)
Backed out changeset 50b20aa3fd46 (bug 1159385)
Backed out changeset 863379c3fe31 (bug 1159385)
Backed out changeset 8decc8f8fcb1 (bug 1165558)
This commit is contained in:
Phil Ringnalda 2015-10-13 21:36:10 -07:00
parent 122a5a5176
commit bad48ad6fa
7 changed files with 328 additions and 323 deletions

View File

@ -1,4 +1,5 @@
[DEFAULT]
skip-if = e10s # Bug 1159385
support-files = file_pdfjs_test.pdf
[browser_pdfjs_main.js]

View File

@ -4,7 +4,9 @@
const RELATIVE_DIR = "browser/extensions/pdfjs/test/";
const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR;
add_task(function* test() {
function test() {
var tab;
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');
@ -15,68 +17,70 @@ add_task(function* test() {
info('Pref action: ' + handlerInfo.preferredAction);
yield BrowserTestUtils.withNewTab({ gBrowser: gBrowser, url: TESTROOT + "file_pdfjs_test.pdf" },
function* (newTabBrowser) {
ok(gBrowser.isFindBarInitialized(), "Browser FindBar initialized!");
waitForExplicitFinish();
registerCleanupFunction(function() {
gBrowser.removeTab(tab);
});
//
// Overall sanity tests
//
let [ viewer, PDFJS ] = yield ContentTask.spawn(newTabBrowser, null, function() {
return [ content.document.querySelector('div#viewer') !== null,
'PDFJS' in content.wrappedJSObject ];
});
tab = gBrowser.addTab(TESTROOT + "file_pdfjs_test.pdf");
var newTabBrowser = gBrowser.getBrowserForTab(tab);
newTabBrowser.addEventListener("load", function eventHandler() {
newTabBrowser.removeEventListener("load", eventHandler, true);
ok(viewer, "document content has viewer UI");
ok(PDFJS, "window content has PDFJS object");
var document = newTabBrowser.contentDocument,
window = newTabBrowser.contentWindow;
//
// Sidebar: open
//
let contains = yield ContentTask.spawn(newTabBrowser, null, function() {
var sidebar = content.document.querySelector('button#sidebarToggle'),
outerContainer = content.document.querySelector('div#outerContainer');
// Runs tests after all 'load' event handlers have fired off
window.addEventListener("documentload", function() {
runTests(document, window, tab, finish);
}, false, true);
}, true);
}
sidebar.click();
return outerContainer.classList.contains('sidebarOpen');
});
ok(contains, "sidebar opens on click");
function runTests(document, window, tab, callback) {
//
// Sidebar: close
//
contains = yield ContentTask.spawn(newTabBrowser, null, function() {
var sidebar = content.document.querySelector('button#sidebarToggle'),
outerContainer = content.document.querySelector('div#outerContainer');
//
// Overall sanity tests
//
ok(document.querySelector('div#viewer'), "document content has viewer UI");
ok('PDFJS' in window.wrappedJSObject, "window content has PDFJS object");
sidebar.click();
return outerContainer.classList.contains('sidebarOpen');
});
//
// Browser Find
//
ok(gBrowser.isFindBarInitialized(tab), "Browser FindBar initialized!");
ok(!contains, "sidebar closes on click");
//
// Sidebar: open
//
var sidebar = document.querySelector('button#sidebarToggle'),
outerContainer = document.querySelector('div#outerContainer');
//
// Page change from prev/next buttons
//
let pageNumber = yield ContentTask.spawn(newTabBrowser, null, function() {
var prevPage = content.document.querySelector('button#previous'),
nextPage = content.document.querySelector('button#next');
sidebar.click();
ok(outerContainer.classList.contains('sidebarOpen'), 'sidebar opens on click');
return content.document.querySelector('input#pageNumber').value;
});
//
// Sidebar: close
//
sidebar.click();
ok(!outerContainer.classList.contains('sidebarOpen'), 'sidebar closes on click');
is(parseInt(pageNumber), 1, 'initial page is 1');
//
// Page change from prev/next buttons
//
var prevPage = document.querySelector('button#previous'),
nextPage = document.querySelector('button#next');
//
// Bookmark button
//
let numBookmarks = yield ContentTask.spawn(newTabBrowser, null, function() {
var viewBookmark = content.document.querySelector('a#viewBookmark');
viewBookmark.click();
return viewBookmark.href.length;
});
var pageNumber = document.querySelector('input#pageNumber');
is(parseInt(pageNumber.value), 1, 'initial page is 1');
ok(numBookmarks > 0, "viewBookmark button has href");
});
});
//
// Bookmark button
//
var viewBookmark = document.querySelector('a#viewBookmark');
viewBookmark.click();
ok(viewBookmark.href.length > 0, 'viewBookmark button has href');
callback();
}

View File

@ -139,7 +139,9 @@ const TESTS = [
}
];
add_task(function* test() {
function test() {
var tab;
let mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
let handlerInfo = mimeService.getFromTypeAndExtension('application/pdf', 'pdf');
@ -149,85 +151,51 @@ add_task(function* test() {
info('Pref action: ' + handlerInfo.preferredAction);
yield BrowserTestUtils.withNewTab({ gBrowser, url: TESTROOT + "file_pdfjs_test.pdf" },
function* (newTabBrowser) {
// Runs tests after all 'load' event handlers have fired off
yield ContentTask.spawn(newTabBrowser, null, function* () {
yield new Promise((resolve) => {
content.addEventListener("documentload", function() {
resolve();
}, false, true);
});
waitForExplicitFinish();
registerCleanupFunction(function() {
gBrowser.removeTab(tab);
});
tab = gBrowser.addTab(TESTROOT + "file_pdfjs_test.pdf");
gBrowser.selectedTab = tab;
var newTabBrowser = gBrowser.getBrowserForTab(tab);
newTabBrowser.addEventListener("load", function eventHandler() {
newTabBrowser.removeEventListener("load", eventHandler, true);
var document = newTabBrowser.contentDocument,
window = newTabBrowser.contentWindow;
// Runs tests after all 'load' event handlers have fired off
window.addEventListener("documentload", function() {
runTests(document, window, function () {
var pageNumber = document.querySelector('input#pageNumber');
is(pageNumber.value, pageNumber.max, "Document is left on the last page");
finish();
});
}, false, true);
}, true);
}
let [ viewer, pdfjs ] = yield ContentTask.spawn(newTabBrowser, null, function* () {
// Check if PDF is opened with internal viewer
return [ content.document.querySelector('div#viewer') !== null,
'PDFJS' in content.wrappedJSObject ];
});
function runTests(document, window, finish) {
// Check if PDF is opened with internal viewer
ok(document.querySelector('div#viewer'), "document content has viewer UI");
ok('PDFJS' in window.wrappedJSObject, "window content has PDFJS object");
ok(viewer, "document content has viewer UI");
ok(pdfjs, "window content has PDFJS object");
yield ContentTask.spawn(newTabBrowser, null, contentSetUp);
yield Task.spawn(runTests(newTabBrowser));
let [ pageNumberValue, pageNumberMax ] = yield ContentTask.spawn(newTabBrowser, null,
function*() {
let pageNumber = content.document.querySelector('input#pageNumber');
return [ pageNumber.value, pageNumber.max ];
});
is(pageNumberValue, pageNumberMax, "Document is left on the last page");
// Wait for outline items, the start the navigation actions
waitForOutlineItems(document).then(function () {
// The key navigation has to happen in page-fit, otherwise it won't scroll
// trough a complete page
setZoomToPageFit(document).then(function () {
runNextTest(document, window, finish);
}, function () {
ok(false, "Current scale has been set to 'page-fit'");
finish();
});
});
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);
}, function () {
ok(false, "Outline items have been found");
finish();
});
}
/**
@ -239,53 +207,99 @@ function* contentSetUp() {
* @param test
* @param callback
*/
function* runTests(browser) {
for (let test of TESTS) {
let pgNumber = yield ContentTask.spawn(browser, test, function* (test) {
let window = content;
let document = window.document;
function runNextTest(document, window, endCallback) {
var test = TESTS.shift(),
deferred = Promise.defer(),
pageNumber = document.querySelector('input#pageNumber');
let deferred = {};
deferred.promise = new Promise((resolve, reject) => {
deferred.resolve = resolve;
deferred.reject = reject;
});
// Add an event-listener to wait for page to change, afterwards resolve the promise
var 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);
}
});
let pageNumber = document.querySelector('input#pageNumber');
// Get the element and trigger the action for changing the page
var el = document.querySelector(test.action.selector);
ok(el, "Element '" + test.action.selector + "' has been found");
// 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);
}
});
// The value option is for input case
if (test.action.value)
el.value = test.action.value;
// Get the element and trigger the action for changing the page
var el = document.querySelector(test.action.selector);
// 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);
return yield deferred.promise;
});
info("Element '" + test.action.selector + "' has been found");
is(pgNumber, test.expectedPage, test.message);
// 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);
// When the promise gets resolved we call the next test if there are any left
// or else we call the final callback which will end the test
deferred.promise.then(function (pgNumber) {
is(pgNumber, test.expectedPage, test.message);
if (TESTS.length)
runNextTest(document, window, endCallback);
else
endCallback();
}, function () {
ok(false, "Test '" + test.message + "' failed with timeout.");
endCallback();
});
}
/**
* Outline Items gets appended to the document latter on we have to
* wait for them before we start to navigate though document
*
* @param document
* @returns {deferred.promise|*}
*/
function waitForOutlineItems(document) {
var deferred = Promise.defer();
document.addEventListener("outlineloaded", function outlineLoaded(evt) {
document.removeEventListener("outlineloaded", outlineLoaded);
var outlineCount = evt.detail.outlineCount;
if (document.querySelectorAll(".outlineItem").length === outlineCount) {
deferred.resolve();
} else {
deferred.reject();
}
});
return deferred.promise;
}
/**
* The key navigation has to happen in page-fit, otherwise it won't scroll
* trough a complete page
*
* @param document
* @returns {deferred.promise|*}
*/
function setZoomToPageFit(document) {
var deferred = Promise.defer();
document.addEventListener("pagerendered", function onZoom(e) {
document.removeEventListener("pagerendered", onZoom);
document.querySelector("#viewer").click();
deferred.resolve();
});
var select = document.querySelector("select#scaleSelect");
select.selectedIndex = 2;
select.dispatchEvent(new Event("change"));
return deferred.promise;
}

View File

@ -4,7 +4,9 @@
const RELATIVE_DIR = "browser/extensions/pdfjs/test/";
const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR;
add_task(function* test() {
function test() {
var tab;
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');
@ -15,79 +17,60 @@ add_task(function* test() {
info('Pref action: ' + handlerInfo.preferredAction);
yield BrowserTestUtils.withNewTab({ gBrowser, url: TESTROOT + "file_pdfjs_test.pdf" },
function* (browser) {
// check that PDF is opened with internal viewer
let [ viewer, pdfjs ] = yield ContentTask.spawn(browser, null, function* () {
yield new Promise((resolve) => {
content.addEventListener("documentload", function documentload() {
content.removeEventListener("documentload", documentload);
resolve();
});
});
return [ content.document.querySelector('div#viewer') !== null,
'PDFJS' in content.wrappedJSObject ]
});
waitForExplicitFinish();
registerCleanupFunction(function() {
gBrowser.removeTab(tab);
});
ok(viewer, "document content has viewer UI");
ok(pdfjs, "window content has PDFJS object");
tab = gBrowser.addTab(TESTROOT + "file_pdfjs_test.pdf");
var newTabBrowser = gBrowser.getBrowserForTab(tab);
newTabBrowser.addEventListener("load", function eventHandler() {
newTabBrowser.removeEventListener("load", eventHandler, true);
//open sidebar
let sidebarOpen = yield ContentTask.spawn(browser, null, function* () {
var sidebar = content.document.querySelector('button#sidebarToggle');
var outerContainer = content.document.querySelector('div#outerContainer');
var document = newTabBrowser.contentDocument,
window = newTabBrowser.contentWindow;
sidebar.click();
return outerContainer.classList.contains('sidebarOpen');
});
// Runs tests after all 'load' event handlers have fired off
window.addEventListener("documentload", function() {
runTests(document, window, finish);
}, false, true);
}, true);
}
ok(sidebarOpen, 'sidebar opens on click');
function runTests(document, window, callback) {
// check that PDF is opened with internal viewer
ok(document.querySelector('div#viewer'), "document content has viewer UI");
ok('PDFJS' in window.wrappedJSObject, "window content has PDFJS object");
// check that thumbnail view is open
let [ thumbnailClass, outlineClass ] = yield ContentTask.spawn(browser, null, function* () {
var thumbnailView = content.document.querySelector('div#thumbnailView');
var outlineView = content.document.querySelector('div#outlineView');
//open sidebar
var sidebar = document.querySelector('button#sidebarToggle');
var outerContainer = document.querySelector('div#outerContainer');
return [ thumbnailView.getAttribute('class'),
outlineView.getAttribute('class') ]
});
sidebar.click();
ok(outerContainer.classList.contains('sidebarOpen'), 'sidebar opens on click');
is(thumbnailClass, null, 'Initial view is thumbnail view');
is(outlineClass, 'hidden', 'Outline view is hidden initially');
// check that thumbnail view is open
var thumbnailView = document.querySelector('div#thumbnailView');
var outlineView = document.querySelector('div#outlineView');
//switch to outline view
[ thumbnailClass, outlineClass ] = yield ContentTask.spawn(browser, null, function* () {
var viewOutlineButton = content.document.querySelector('button#viewOutline');
viewOutlineButton.click();
is(thumbnailView.getAttribute('class'), null, 'Initial view is thumbnail view');
is(outlineView.getAttribute('class'), 'hidden', 'Outline view is hidden initially');
var thumbnailView = content.document.querySelector('div#thumbnailView');
var outlineView = content.document.querySelector('div#outlineView');
//switch to outline view
var viewOutlineButton = document.querySelector('button#viewOutline');
viewOutlineButton.click();
return [ thumbnailView.getAttribute('class'),
outlineView.getAttribute('class') ];
});
is(outlineView.getAttribute('class'), '', 'Outline view is visible when selected');
is(thumbnailView.getAttribute('class'), 'hidden', 'Thumbnail view is hidden when outline is selected');
is(thumbnailClass, 'hidden', 'Thumbnail view is hidden when outline is selected');
is(outlineClass, '', 'Outline view is visible when selected');
//switch back to thumbnail view
var viewThumbnailButton = document.querySelector('button#viewThumbnail');
viewThumbnailButton.click();
//switch back to thumbnail view
[ thumbnailClass, outlineClass ] = yield ContentTask.spawn(browser, null, function* () {
var viewThumbnailButton = content.document.querySelector('button#viewThumbnail');
viewThumbnailButton.click();
is(thumbnailView.getAttribute('class'), '', 'Thumbnail view is visible when selected');
is(outlineView.getAttribute('class'), 'hidden', 'Outline view is hidden when thumbnail is selected');
var thumbnailView = content.document.querySelector('div#thumbnailView');
var outlineView = content.document.querySelector('div#outlineView');
sidebar.click();
let rval = [ thumbnailView.getAttribute('class'),
outlineView.getAttribute('class') ];
var sidebar = content.document.querySelector('button#sidebarToggle');
sidebar.click();
return rval;
});
is(thumbnailClass, '', 'Thumbnail view is visible when selected');
is(outlineClass, 'hidden', 'Outline view is hidden when thumbnail is selected');
});
});
callback();
}

View File

@ -28,7 +28,6 @@ const TESTS = [
{
action: {
keyboard: true,
keyCode: 61,
event: "+"
},
expectedZoom: 1, // 1 - zoom in
@ -38,7 +37,6 @@ const TESTS = [
{
action: {
keyboard: true,
keyCode: 109,
event: "-"
},
expectedZoom: -1, // -1 - zoom out
@ -56,7 +54,11 @@ const TESTS = [
}
];
add_task(function* test() {
var initialWidth; // the initial width of the PDF document
var previousWidth; // the width of the PDF document at previous step/test
function test() {
var tab;
let handlerService = Cc["@mozilla.org/uriloader/handler-service;1"]
.getService(Ci.nsIHandlerService);
let mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
@ -70,101 +72,104 @@ add_task(function* test() {
info('Pref action: ' + handlerInfo.preferredAction);
yield BrowserTestUtils.withNewTab({ gBrowser, url: TESTROOT + "file_pdfjs_test.pdf" },
function* (newTabBrowser) {
let initialWidth = 0; // the initial width of the PDF document
let previousWidth = 0; // the width of the PDF document at previous step/test
waitForExplicitFinish();
registerCleanupFunction(function() {
gBrowser.removeTab(tab);
});
initialWidth = previousWidth =
yield ContentTask.spawn(newTabBrowser, null, function* () {
// Runs tests after all 'load' event handlers have fired off
return yield new Promise((resolve) => {
content.addEventListener("documentload", function loaded() {
content.removeEventListener("documentload", loaded);
resolve(parseInt(content.document.querySelector("div#pageContainer1").style.width));
}, false, true);
});
});
tab = gBrowser.selectedTab = gBrowser.addTab(TESTROOT + "file_pdfjs_test.pdf");
var newTabBrowser = gBrowser.getBrowserForTab(tab);
// Basic tests.
let [ viewer, pdfjs ] = yield ContentTask.spawn(newTabBrowser, null, function* () {
// check that PDF is opened with internal viewer
return [ content.document.querySelector('div#viewer') !== null,
'PDFJS' in content.wrappedJSObject ];
});
newTabBrowser.addEventListener("load", function eventHandler() {
newTabBrowser.removeEventListener("load", eventHandler, true);
ok(viewer, "document content has viewer UI");
ok(pdfjs, "window content has PDFJS object");
var document = newTabBrowser.contentDocument,
window = newTabBrowser.contentWindow;
for (let test of TESTS) {
yield ContentTask.spawn(newTabBrowser, test, function* (test) {
let document = content.document;
// Runs tests after all 'load' event handlers have fired off
window.addEventListener("documentload", function() {
initialWidth = parseInt(document.querySelector("div#pageContainer1").style.width);
previousWidth = initialWidth;
runTests(document, window, finish);
}, false, true);
}, true);
}
function waitForRender() {
return new Promise((resolve) => {
document.addEventListener("pagerendered", function onPageRendered(e) {
if(e.detail.pageNumber !== 1) {
return;
}
function runTests(document, window, callback) {
// check that PDF is opened with internal viewer
ok(document.querySelector('div#viewer'), "document content has viewer UI");
ok('PDFJS' in window.wrappedJSObject, "window content has PDFJS object");
document.removeEventListener("pagerendered", onPageRendered, true);
resolve();
}, true);
});
}
// Start the zooming tests after the document is loaded
waitForDocumentLoad(document).then(function () {
zoomPDF(document, window, TESTS.shift(), finish);
});
}
// 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);
function waitForDocumentLoad(document) {
var deferred = Promise.defer();
var interval = setInterval(function () {
if (document.querySelector("div#pageContainer1") != null){
clearInterval(interval);
deferred.resolve();
}
}, 500);
if (test.action.index){
el.selectedIndex = test.action.index;
}
return deferred.promise;
}
// 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;
}
function zoomPDF(document, window, test, endCallback) {
var renderedPage;
el.dispatchEvent(ev);
yield waitForRender();
});
document.addEventListener("pagerendered", function onPageRendered(e) {
if(e.detail.pageNumber !== 1) {
return;
}
if (test.action.selector) {
info("Element '" + test.action.selector + "' has been found");
}
document.removeEventListener("pagerendered", onPageRendered, true);
let { actualWidth, zoomValue } = yield ContentTask.spawn(newTabBrowser, null, function* () {
var pageZoomScale = content.document.querySelector('select#scaleSelect');
var pageZoomScale = document.querySelector('select#scaleSelect');
// The zoom value displayed in the zoom select
var zoomValue = pageZoomScale.options[pageZoomScale.selectedIndex].innerHTML;
// 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);
let pageContainer = document.querySelector('div#pageContainer1');
let actualWidth = parseInt(pageContainer.style.width);
return { actualWidth, zoomValue };
});
// the actual zoom of the PDF document
let computedZoomValue = parseInt(((actualWidth/initialWidth).toFixed(2))*100) + "%";
is(computedZoomValue, zoomValue, "Content has correct zoom");
// the actual zoom of the PDF document
let computedZoomValue = parseInt(((actualWidth/initialWidth).toFixed(2))*100) + "%";
is(computedZoomValue, zoomValue, "Content has correct zoom");
// Check that document zooms in the expected way (in/out)
let zoom = (actualWidth - previousWidth) * test.expectedZoom;
ok(zoom > 0, test.message);
// Check that document zooms in the expected way (in/out)
let zoom = (actualWidth - previousWidth) * test.expectedZoom;
ok(zoom > 0, test.message);
// Go to next test (if there is any) or finish
var nextTest = TESTS.shift();
if (nextTest) {
previousWidth = actualWidth;
zoomPDF(document, window, nextTest, endCallback);
}
else
endCallback();
}, true);
previousWidth = actualWidth;
}
});
});
// We zoom using an UI element
if (test.action.selector) {
// Get the element and trigger the action for changing the zoom
var el = document.querySelector(test.action.selector);
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
el.dispatchEvent(new Event(test.action.event));
}
// We zoom using keyboard
else {
// Simulate key press
EventUtils.synthesizeKey(test.action.event, { ctrlKey: true });
}
}

View File

@ -321,7 +321,7 @@ this.BrowserTestUtils = {
* Waits for an event to be fired on a specified element.
*
* Usage:
* let promiseEvent = BrowserTestUtils.waitForEvent(element, "eventName");
* let promiseEvent = BrowserTestUtil.waitForEvent(element, "eventName");
* // Do some processing here that will cause the event to be fired
* // ...
* // Now yield until the Promise is fulfilled

View File

@ -396,9 +396,7 @@ ExternalHelperAppParent::SetContentCharset(const nsACString& aContentCharset)
NS_IMETHODIMP
ExternalHelperAppParent::GetContentDisposition(uint32_t *aContentDisposition)
{
// NB: mContentDisposition may or may not be set to a non UINT32_MAX value in
// nsExternalHelperAppService::DoContentContentProcessHelper
if (mContentDispositionHeader.IsEmpty() && mContentDisposition == UINT32_MAX)
if (mContentDispositionHeader.IsEmpty())
return NS_ERROR_NOT_AVAILABLE;
*aContentDisposition = mContentDisposition;