зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 99fd6973d18e (bug 1332386) for frequently failing browser_tabSwitchPrintPreview.js on Linux x64 opt-ish builds. r=backout a=backout
MozReview-Commit-ID: 7oyiuBSTGtI
This commit is contained in:
Родитель
38fdbbcaa4
Коммит
8961c1494e
|
@ -3488,41 +3488,23 @@ function getPEMString(cert) {
|
|||
|
||||
var PrintPreviewListener = {
|
||||
_printPreviewTab: null,
|
||||
_simplifiedPrintPreviewTab: null,
|
||||
_tabBeforePrintPreview: null,
|
||||
_simplifyPageTab: null,
|
||||
_lastRequestedPrintPreviewTab: null,
|
||||
|
||||
_createPPBrowser() {
|
||||
if (!this._tabBeforePrintPreview) {
|
||||
this._tabBeforePrintPreview = gBrowser.selectedTab;
|
||||
}
|
||||
let browser = this._tabBeforePrintPreview.linkedBrowser;
|
||||
let preferredRemoteType = browser.remoteType;
|
||||
return gBrowser.loadOneTab("about:printpreview", {
|
||||
inBackground: true,
|
||||
preferredRemoteType,
|
||||
sameProcessAsFrameLoader: browser.frameLoader
|
||||
});
|
||||
},
|
||||
getPrintPreviewBrowser() {
|
||||
if (!this._printPreviewTab) {
|
||||
this._printPreviewTab = this._createPPBrowser();
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
let preferredRemoteType = browser.remoteType;
|
||||
this._tabBeforePrintPreview = gBrowser.selectedTab;
|
||||
this._printPreviewTab = gBrowser.loadOneTab("about:printpreview", {
|
||||
inBackground: false,
|
||||
preferredRemoteType,
|
||||
sameProcessAsFrameLoader: browser.frameLoader
|
||||
});
|
||||
gBrowser.selectedTab = this._printPreviewTab;
|
||||
}
|
||||
gBrowser._allowTabChange = true;
|
||||
this._lastRequestedPrintPreviewTab = gBrowser.selectedTab = this._printPreviewTab;
|
||||
gBrowser._allowTabChange = false;
|
||||
return gBrowser.getBrowserForTab(this._printPreviewTab);
|
||||
},
|
||||
getSimplifiedPrintPreviewBrowser() {
|
||||
if (!this._simplifiedPrintPreviewTab) {
|
||||
this._simplifiedPrintPreviewTab = this._createPPBrowser();
|
||||
}
|
||||
gBrowser._allowTabChange = true;
|
||||
this._lastRequestedPrintPreviewTab = gBrowser.selectedTab = this._simplifiedPrintPreviewTab;
|
||||
gBrowser._allowTabChange = false;
|
||||
return gBrowser.getBrowserForTab(this._simplifiedPrintPreviewTab);
|
||||
},
|
||||
createSimplifiedBrowser() {
|
||||
let browser = this._tabBeforePrintPreview.linkedBrowser;
|
||||
this._simplifyPageTab = gBrowser.loadOneTab("about:printpreview", {
|
||||
|
@ -3545,8 +3527,8 @@ var PrintPreviewListener = {
|
|||
onEnter() {
|
||||
// We might have accidentally switched tabs since the user invoked print
|
||||
// preview
|
||||
if (gBrowser.selectedTab != this._lastRequestedPrintPreviewTab) {
|
||||
gBrowser.selectedTab = this._lastRequestedPrintPreviewTab;
|
||||
if (gBrowser.selectedTab != this._printPreviewTab) {
|
||||
gBrowser.selectedTab = this._printPreviewTab;
|
||||
}
|
||||
gInPrintPreviewMode = true;
|
||||
this._toggleAffectedChrome();
|
||||
|
@ -3556,15 +3538,13 @@ var PrintPreviewListener = {
|
|||
this._tabBeforePrintPreview = null;
|
||||
gInPrintPreviewMode = false;
|
||||
this._toggleAffectedChrome();
|
||||
let tabsToRemove = ["_simplifyPageTab", "_printPreviewTab", "_simplifiedPrintPreviewTab"];
|
||||
for (let tabProp of tabsToRemove) {
|
||||
if (this[tabProp]) {
|
||||
gBrowser.removeTab(this[tabProp]);
|
||||
this[tabProp] = null;
|
||||
}
|
||||
if (this._simplifyPageTab) {
|
||||
gBrowser.removeTab(this._simplifyPageTab);
|
||||
this._simplifyPageTab = null;
|
||||
}
|
||||
gBrowser.removeTab(this._printPreviewTab);
|
||||
gBrowser.deactivatePrintPreviewBrowsers();
|
||||
this._lastRequestedPrintPreviewTab = null;
|
||||
this._printPreviewTab = null;
|
||||
},
|
||||
_toggleAffectedChrome() {
|
||||
gNavToolbox.collapsed = gInPrintPreviewMode;
|
||||
|
|
|
@ -3401,7 +3401,7 @@
|
|||
</getter>
|
||||
<setter>
|
||||
<![CDATA[
|
||||
if (gNavToolbox.collapsed && !this._allowTabChange) {
|
||||
if (gNavToolbox.collapsed) {
|
||||
return this.mTabBox.selectedTab;
|
||||
}
|
||||
// Update the tab
|
||||
|
|
|
@ -175,16 +175,6 @@
|
|||
</body>
|
||||
</method>
|
||||
|
||||
<method name="destroy">
|
||||
<body>
|
||||
<![CDATA[
|
||||
this.mMessageManager.removeMessageListener("Printing:Preview:UpdatePageCount", this);
|
||||
delete this.mMessageManager;
|
||||
delete this.mPPBrowser;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="doPageSetup">
|
||||
<body>
|
||||
<![CDATA[
|
||||
|
|
|
@ -183,21 +183,11 @@ var PrintUtils = {
|
|||
* Returns the <xul:browser> to display the print preview in. This
|
||||
* <xul:browser> must have its type attribute set to "content".
|
||||
*
|
||||
* getSimplifiedPrintPreviewBrowser:
|
||||
* Returns the <xul:browser> to display the simplified print preview
|
||||
* in. This <xul:browser> must have its type attribute set to
|
||||
* "content".
|
||||
*
|
||||
* getSourceBrowser:
|
||||
* Returns the <xul:browser> that contains the document being
|
||||
* printed. This <xul:browser> must have its type attribute set to
|
||||
* "content".
|
||||
*
|
||||
* getSimplifiedSourceBrowser:
|
||||
* Returns the <xul:browser> that contains the simplified version
|
||||
* of the document being printed. This <xul:browser> must have its
|
||||
* type attribute set to "content".
|
||||
*
|
||||
* getNavToolbox:
|
||||
* Returns the primary toolbox for this window.
|
||||
*
|
||||
|
@ -230,9 +220,7 @@ var PrintUtils = {
|
|||
// issues in bug 267422.
|
||||
// We use the print preview browser as the source browser to avoid
|
||||
// re-initializing print preview with a document that might now have changed.
|
||||
this._sourceBrowser = this._shouldSimplify ?
|
||||
this._listener.getSimplifiedPrintPreviewBrowser() :
|
||||
this._listener.getPrintPreviewBrowser();
|
||||
this._sourceBrowser = this._listener.getPrintPreviewBrowser();
|
||||
this._sourceBrowser.collapsed = true;
|
||||
|
||||
// If the user transits too quickly within preview and we have a pending
|
||||
|
@ -319,7 +307,7 @@ var PrintUtils = {
|
|||
return {};
|
||||
}
|
||||
|
||||
return this._currentPPBrowser.docShell.printPreview;
|
||||
return this._listener.getPrintPreviewBrowser().docShell.printPreview;
|
||||
},
|
||||
|
||||
get inPrintPreview() {
|
||||
|
@ -513,41 +501,13 @@ var PrintUtils = {
|
|||
this._shouldSimplify = shouldSimplify;
|
||||
},
|
||||
|
||||
/**
|
||||
* Currently, we create a new print preview browser to host the simplified
|
||||
* cloned-document when Simplify Page option is used on preview. To accomplish
|
||||
* this, we need to keep track of what browser should be presented, based on
|
||||
* whether the 'Simplify page' checkbox is checked.
|
||||
*
|
||||
* _ppBrowsers
|
||||
* Set of print preview browsers.
|
||||
* _currentPPBrowser
|
||||
* References the current print preview browser that is being presented.
|
||||
*/
|
||||
_ppBrowsers: new Set(),
|
||||
_currentPPBrowser: null,
|
||||
|
||||
enterPrintPreview() {
|
||||
// Send a message to the print preview browser to initialize
|
||||
// print preview. If we happen to have gotten a print preview
|
||||
// progress listener from nsIPrintingPromptService.showProgress
|
||||
// in printPreview, we add listeners to feed that progress
|
||||
// listener.
|
||||
let ppBrowser = this._shouldSimplify ?
|
||||
this._listener.getSimplifiedPrintPreviewBrowser() :
|
||||
this._listener.getPrintPreviewBrowser();
|
||||
this._ppBrowsers.add(ppBrowser);
|
||||
|
||||
// If we're switching from 'normal' print preview to 'simplified' print
|
||||
// preview, we will want to run reader mode against the 'normal' print
|
||||
// preview browser's content:
|
||||
let oldPPBrowser = null;
|
||||
let changingPrintPreviewBrowsers = false;
|
||||
if (this._currentPPBrowser && ppBrowser != this._currentPPBrowser) {
|
||||
changingPrintPreviewBrowsers = true;
|
||||
oldPPBrowser = this._currentPPBrowser;
|
||||
}
|
||||
this._currentPPBrowser = ppBrowser;
|
||||
let ppBrowser = this._listener.getPrintPreviewBrowser();
|
||||
let mm = ppBrowser.messageManager;
|
||||
let defaultPrinterName = this.getDefaultPrinterName();
|
||||
|
||||
|
@ -555,7 +515,6 @@ var PrintUtils = {
|
|||
mm.sendAsyncMessage("Printing:Preview:Enter", {
|
||||
windowID: browser.outerWindowID,
|
||||
simplifiedMode: simplified,
|
||||
changingBrowsers: changingPrintPreviewBrowsers,
|
||||
defaultPrinterName,
|
||||
});
|
||||
};
|
||||
|
@ -586,7 +545,7 @@ var PrintUtils = {
|
|||
// that the document is ready for print previewing.
|
||||
spMM.sendAsyncMessage("Printing:Preview:ParseDocument", {
|
||||
URL: this._originalURL,
|
||||
windowID: oldPPBrowser.outerWindowID,
|
||||
windowID: this._sourceBrowser.outerWindowID,
|
||||
});
|
||||
|
||||
// Here we log telemetry data for when the user enters simplify mode.
|
||||
|
@ -618,10 +577,6 @@ var PrintUtils = {
|
|||
|
||||
let printPreviewTB = document.getElementById("print-preview-toolbar");
|
||||
if (printPreviewTB) {
|
||||
if (message.data.changingBrowsers) {
|
||||
printPreviewTB.destroy();
|
||||
printPreviewTB.initialize(ppBrowser);
|
||||
}
|
||||
printPreviewTB.updateToolbar();
|
||||
ppBrowser.collapsed = false;
|
||||
ppBrowser.focus();
|
||||
|
@ -678,12 +633,9 @@ var PrintUtils = {
|
|||
},
|
||||
|
||||
exitPrintPreview() {
|
||||
for (let browser of this._ppBrowsers) {
|
||||
let browserMM = browser.messageManager;
|
||||
browserMM.sendAsyncMessage("Printing:Preview:Exit");
|
||||
}
|
||||
this._ppBrowsers.clear();
|
||||
this._currentPPBrowser = null;
|
||||
let ppBrowser = this._listener.getPrintPreviewBrowser();
|
||||
let browserMM = ppBrowser.messageManager;
|
||||
browserMM.sendAsyncMessage("Printing:Preview:Exit");
|
||||
window.removeEventListener("keydown", this.onKeyDownPP, true);
|
||||
window.removeEventListener("keypress", this.onKeyPressPP, true);
|
||||
|
||||
|
@ -693,8 +645,7 @@ var PrintUtils = {
|
|||
|
||||
// remove the print preview toolbar
|
||||
let printPreviewTB = document.getElementById("print-preview-toolbar");
|
||||
printPreviewTB.destroy();
|
||||
printPreviewTB.remove();
|
||||
this._listener.getNavToolbox().parentNode.removeChild(printPreviewTB);
|
||||
|
||||
let fm = Components.classes["@mozilla.org/focus-manager;1"]
|
||||
.getService(Components.interfaces.nsIFocusManager);
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
module.exports = {
|
||||
"extends": [
|
||||
"plugin:mozilla/chrome-test",
|
||||
"plugin:mozilla/browser-test"
|
||||
"plugin:mozilla/chrome-test"
|
||||
],
|
||||
};
|
||||
|
|
|
@ -1,7 +1,2 @@
|
|||
[browser_page_change_print_original.js]
|
||||
skip-if = os == "mac"
|
||||
|
||||
[browser_preview_switch_print_selected.js]
|
||||
support-files =
|
||||
simplifyArticleSample.html
|
||||
skip-if = os == "mac"
|
|
@ -1,104 +0,0 @@
|
|||
/**
|
||||
* Verify if we correctly switch print preview browsers based on whether
|
||||
* Simplify Page checkbox is checked.
|
||||
*/
|
||||
|
||||
const TEST_PATH = getRootDirectory(gTestPath)
|
||||
.replace("chrome://mochitests/content", "http://example.com");
|
||||
|
||||
add_task(function* set_simplify_and_reader_pref() {
|
||||
// Ensure we have the simplify page preference set
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["print.use_simplify_page", true],
|
||||
["reader.parse-on-load.enabled", true]
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* switch_print_preview_browsers() {
|
||||
let url = TEST_PATH + "simplifyArticleSample.html";
|
||||
|
||||
// Can only do something if we have a print preview UI:
|
||||
if (AppConstants.platform != "win" && AppConstants.platform != "linux") {
|
||||
ok(false, "Can't test if there's no print preview.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure we get a browserStopped for this browser
|
||||
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, url, false, true);
|
||||
|
||||
// Wait for Reader Mode to parse and set property of loaded tab
|
||||
yield BrowserTestUtils.waitForCondition(() => {
|
||||
return tab.linkedBrowser.isArticle;
|
||||
});
|
||||
|
||||
// Enter print preview
|
||||
let defaultPPBrowser = PrintPreviewListener.getPrintPreviewBrowser();
|
||||
let defaultPPEntered = BrowserTestUtils
|
||||
.waitForMessage(defaultPPBrowser.messageManager,
|
||||
"Printing:Preview:Entered");
|
||||
document.getElementById("cmd_printPreview").doCommand();
|
||||
yield defaultPPEntered;
|
||||
|
||||
// Assert that we are showing the initial content on default print preview browser
|
||||
yield ContentTask.spawn(defaultPPBrowser, null, function* () {
|
||||
is(content.document.title, "Article title", "Should have initial content.");
|
||||
});
|
||||
|
||||
// Here we call simplified mode
|
||||
let simplifiedPPBrowser = PrintPreviewListener.getSimplifiedPrintPreviewBrowser();
|
||||
let simplifiedPPEntered = BrowserTestUtils
|
||||
.waitForMessage(simplifiedPPBrowser.messageManager,
|
||||
"Printing:Preview:Entered");
|
||||
let printPreviewToolbar = document.getElementById("print-preview-toolbar");
|
||||
|
||||
// Wait for simplify page option enablement
|
||||
yield BrowserTestUtils.waitForCondition(() => {
|
||||
return !printPreviewToolbar.mSimplifyPageCheckbox.disabled;
|
||||
});
|
||||
|
||||
printPreviewToolbar.mSimplifyPageCheckbox.click();
|
||||
yield simplifiedPPEntered;
|
||||
|
||||
// Assert that simplify page option is checked
|
||||
is(printPreviewToolbar.mSimplifyPageCheckbox.checked, true,
|
||||
"Should have simplify page option checked");
|
||||
|
||||
// Assert that we are showing custom content on simplified print preview browser
|
||||
yield ContentTask.spawn(simplifiedPPBrowser, null, function* () {
|
||||
is(content.document.title, "Article title", "Should have custom content.");
|
||||
});
|
||||
|
||||
// Assert that we are selecting simplified print preview browser, and not default one
|
||||
is(gBrowser.selectedTab.linkedBrowser, simplifiedPPBrowser,
|
||||
"Should have simplified print preview browser selected");
|
||||
isnot(gBrowser.selectedTab.linkedBrowser, defaultPPBrowser,
|
||||
"Should not have default print preview browser selected");
|
||||
|
||||
// Switch back to default print preview content
|
||||
defaultPPEntered = BrowserTestUtils
|
||||
.waitForMessage(defaultPPBrowser.messageManager,
|
||||
"Printing:Preview:Entered");
|
||||
printPreviewToolbar.mSimplifyPageCheckbox.click();
|
||||
yield defaultPPEntered;
|
||||
|
||||
// Assert that simplify page option is not checked
|
||||
isnot(printPreviewToolbar.mSimplifyPageCheckbox.checked, true,
|
||||
"Should not have simplify page option checked");
|
||||
|
||||
// Assert that we are showing the initial content on default print preview browser
|
||||
yield ContentTask.spawn(defaultPPBrowser, null, function* () {
|
||||
is(content.document.title, "Article title", "Should have initial content.");
|
||||
});
|
||||
|
||||
// Assert that we are selecting default print preview browser, and not simplified one
|
||||
is(gBrowser.selectedTab.linkedBrowser, defaultPPBrowser,
|
||||
"Should have default print preview browser selected");
|
||||
isnot(gBrowser.selectedTab.linkedBrowser, simplifiedPPBrowser,
|
||||
"Should not have simplified print preview browser selected");
|
||||
|
||||
PrintUtils.exitPrintPreview();
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
});
|
|
@ -1,16 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Article title</title>
|
||||
<meta name="description" content="This is the article description." />
|
||||
</head>
|
||||
<body>
|
||||
<header>Site header</header>
|
||||
<div>
|
||||
<h1>Article title</h1>
|
||||
<h2 class="author">by Jane Doe</h2>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetu</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetu</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetu</p>
|
||||
</body>
|
||||
</html>
|
|
@ -445,7 +445,7 @@ var Printing = {
|
|||
let data = message.data;
|
||||
switch (message.name) {
|
||||
case "Printing:Preview:Enter": {
|
||||
this.enterPrintPreview(Services.wm.getOuterWindowWithId(data.windowID), data.simplifiedMode, data.changingBrowsers, data.defaultPrinterName);
|
||||
this.enterPrintPreview(Services.wm.getOuterWindowWithId(data.windowID), data.simplifiedMode, data.defaultPrinterName);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -622,7 +622,7 @@ var Printing = {
|
|||
});
|
||||
},
|
||||
|
||||
enterPrintPreview(contentWindow, simplifiedMode, changingBrowsers, defaultPrinterName) {
|
||||
enterPrintPreview(contentWindow, simplifiedMode, defaultPrinterName) {
|
||||
// We'll call this whenever we've finished reflowing the document, or if
|
||||
// we errored out while attempting to print preview (in which case, we'll
|
||||
// notify the parent that we've failed).
|
||||
|
@ -630,7 +630,6 @@ var Printing = {
|
|||
removeEventListener("printPreviewUpdate", onPrintPreviewReady);
|
||||
sendAsyncMessage("Printing:Preview:Entered", {
|
||||
failed: !!error,
|
||||
changingBrowsers,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче