Bug 1379117 Part 1: MOZ_ASSERT when not retrieving nsIWebBrowserPrint through docshell for Print Preview. r=jwatt

Changing the last retrieval of the nsIWebBrowserPrint in
printpreview_bug396024_helper.xul caused problems because doing it via the
docshell interrupts the load that triggers run5.
So, I moved the test to run5, which is more consistent with run2 and run3.
I then realised that the frames would have switched anyway, so I changed it to
retrieve frame[0] for the last test, which I think makes more sense.
It's not totally clear to me what this was testing originally or whether it
continued to do so after the addition of the second iframe a long time ago.
This commit is contained in:
Bob Owen 2018-02-08 08:59:20 +00:00
Родитель d6977c62c9
Коммит b3ae9277a2
4 изменённых файлов: 12 добавлений и 20 удалений

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

@ -3946,9 +3946,8 @@ nsDocumentViewer::PrintPreview(nsIPrintSettings* aPrintSettings,
nsIWebProgressListener* aWebProgressListener)
{
#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
NS_WARNING_ASSERTION(
IsInitializedForPrintPreview(),
"Using docshell.printPreview is the preferred way for print previewing!");
MOZ_ASSERT(IsInitializedForPrintPreview(),
"For print preview nsIWebBrowserPrint must be from docshell.printPreview!");
NS_ENSURE_ARG_POINTER(aChildDOMWin);
nsresult rv = NS_OK;

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

@ -17,8 +17,7 @@ var todo = window.opener.wrappedJSObject.todo;
var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
var gWbp;
function printpreview() {
gWbp = window.frames[1].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
gWbp = window.frames[1].document.docShell.printPreview;
var listener = {
onLocationChange: function(webProgress, request, location, flags) { },
onProgressChange: function(webProgress, request, curSelfProgress,
@ -44,8 +43,7 @@ function printpreview() {
}
function exitprintpreview() {
window.frames[1].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint).exitPrintPreview();
window.frames[1].document.docShell.printPreview.exitPrintPreview();
}
function finish() {
@ -91,8 +89,7 @@ function run2() {
}
function run3() {
gWbp = window.frames[1].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
gWbp = window.frames[1].document.docShell.printPreview;
ok(gWbp.doingPrintPreview, "Should be doing print preview");
exitprintpreview();
setTimeout(run4, 0);
@ -108,12 +105,12 @@ function run4() {
i.addEventListener("load", loadhandler, true);
document.documentElement.getBoundingClientRect();
document.documentElement.appendChild(i);
gWbp = window.frames[1].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
ok(!gWbp.doingPrintPreview, "Should not be doing print preview anymore2");
}
function run5() {
gWbp = window.frames[0].document.docShell.printPreview;
ok(!gWbp.doingPrintPreview, "Should not be doing print preview anymore2");
//XXX this shouldn't be necessary, see bug 405555
printpreview();
exitprintpreview();

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

@ -17,8 +17,7 @@ var todo = window.opener.wrappedJSObject.todo;
var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
var gWbp;
function printpreview() {
gWbp = window.frames[1].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
gWbp = window.frames[1].document.docShell.printPreview;
var listener = {
onLocationChange: function(webProgress, request, location, flags) { },
onProgressChange: function(webProgress, request, curSelfProgress,
@ -44,8 +43,7 @@ function printpreview() {
}
function exitprintpreview() {
window.frames[1].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint).exitPrintPreview();
window.frames[1].document.docShell.printPreview.exitPrintPreview();
}
function finish() {

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

@ -24,8 +24,7 @@ var file = Components.classes["@mozilla.org/file/directory_service;1"]
filePath = file.path;
function printpreview() {
gWbp = window.frames[1].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
gWbp = window.frames[1].document.docShell.printPreview;
var listener = {
onLocationChange: function(webProgress, request, location, flags) { },
onProgressChange: function(webProgress, request, curSelfProgress,
@ -61,8 +60,7 @@ function printpreview() {
}
function exitprintpreview() {
window.frames[1].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint).exitPrintPreview();
window.frames[1].document.docShell.printPreview.exitPrintPreview();
}
function finish() {