Bug 671976 - Fix print preview asserts (r=smaug)

This commit is contained in:
Bill McCloskey 2013-03-14 12:02:28 -07:00
parent 56e47afd26
commit 8e048462e3
8 changed files with 12 additions and 76 deletions

View File

@ -14,7 +14,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=396024
var is = window.opener.wrappedJSObject.is;
var ok = window.opener.wrappedJSObject.ok;
var todo = window.opener.wrappedJSObject.todo;
var parentFinish = window.opener.wrappedJSObject.parentFinish;
var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
var gWbp;
function printpreview() {
gWbp = window.frames[1].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
@ -49,7 +49,7 @@ function exitprintpreview() {
}
function finish() {
parentFinish();
SimpleTest.finish();
window.close();
}

View File

@ -14,7 +14,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=482976
var is = window.opener.wrappedJSObject.is;
var ok = window.opener.wrappedJSObject.ok;
var todo = window.opener.wrappedJSObject.todo;
var parentFinish = window.opener.wrappedJSObject.parentFinish;
var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
var gWbp;
function printpreview() {
gWbp = window.frames[1].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
@ -49,7 +49,7 @@ function exitprintpreview() {
}
function finish() {
parentFinish();
SimpleTest.finish();
window.close();
}

View File

@ -12,7 +12,7 @@ var is = window.opener.wrappedJSObject.is;
var isnot = window.opener.wrappedJSObject.isnot;
var ok = window.opener.wrappedJSObject.ok;
var todo = window.opener.wrappedJSObject.todo;
var parentFinish = window.opener.wrappedJSObject.parentFinish;
var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
var gWbp;
var ctx1;
var ctx2;
@ -66,7 +66,7 @@ function exitprintpreview() {
}
function finish() {
parentFinish();
SimpleTest.finish();
window.close();
}

View File

@ -10,28 +10,6 @@
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
if (navigator.platform.startsWith("Linux")) {
SimpleTest.expectAssertions(1); // bug 671976
} else if (navigator.platform.startsWith("Win")) {
// reliable 1 on Win7, but not on XP
SimpleTest.expectAssertions(0, 1); // bug 671976
}
function parentFinish() {
// This is called while the helper window is still open. Call
// doGC after it closes.
setTimeout(doGC, 0);
}
function doGC() {
// Garbage collecting the windows created in this test can cause
// assertions, so GC now to blame those assertions to this test.
// ("Destroying a currently-showing document", bug 671976)
SpecialPowers.gc();
setTimeout(doFinish, 0);
}
function doFinish() {
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
window.open("printpreview_helper.xul", "printpreview", "chrome,width=100,height=100");
]]></script>

View File

@ -16,28 +16,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=396024
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
if (navigator.platform.startsWith("Linux")) {
SimpleTest.expectAssertions(2); // bug 671976
} else if (navigator.platform.startsWith("Win")) {
// reliable 2 on Win7, but not on XP
SimpleTest.expectAssertions(0, 2); // bug 671976
}
function parentFinish() {
// This is called while the helper window is still open. Call
// doGC after it closes.
setTimeout(doGC, 0);
}
function doGC() {
// Garbage collecting the windows created in this test can cause
// assertions, so GC now to blame those assertions to this test.
// ("Destroying a currently-showing document", bug 671976)
SpecialPowers.gc();
setTimeout(doFinish, 0);
}
function doFinish() {
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
window.open("printpreview_bug396024_helper.xul", "bug396024", "chrome,width=100,height=100");
]]></script>

View File

@ -16,28 +16,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=482976
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
if (navigator.platform.startsWith("Linux")) {
SimpleTest.expectAssertions(1); // bug 671976
} else if (navigator.platform.startsWith("Win")) {
SimpleTest.expectAssertions(0, 2); // bug 671976
}
SimpleTest.waitForExplicitFinish();
function parentFinish() {
// This is called while the helper window is still open. Call
// doGC after it closes.
setTimeout(doGC, 0);
}
function doGC() {
// Garbage collecting the windows created in this test can cause
// assertions, so GC now to blame those assertions to this test.
// ("Destroying a currently-showing document", bug 671976)
SpecialPowers.gc();
setTimeout(doFinish, 0);
}
function doFinish() {
SimpleTest.finish();
}
window.open("printpreview_bug482976_helper.xul", "bug482976", "chrome,width=100,height=100");
]]></script>
</window>

View File

@ -14,11 +14,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=536567
<p id="display"></p>
<pre id="test">
<script type="application/javascript">
if (navigator.platform.startsWith("Win")) {
SimpleTest.expectAssertions(0, 1); // bug 671976 assertions leak to this test on Windows
}
/** Test for Bug 536567 **/
const Cc = Components.classes;

View File

@ -530,6 +530,12 @@ nsPrintEngine::DoCommonPrint(bool aIsPrintPreview,
NS_ENSURE_SUCCESS(rv, rv);
{
nsCOMPtr<nsIContentViewer> viewer;
webContainer->GetContentViewer(getter_AddRefs(viewer));
if (viewer && viewer->GetDocument() && viewer->GetDocument()->IsShowing()) {
viewer->GetDocument()->OnPageHide(false, nullptr);
}
nsAutoScriptBlocker scriptBlocker;
mPrt->mPrintObject = new nsPrintObject();
NS_ENSURE_TRUE(mPrt->mPrintObject, NS_ERROR_OUT_OF_MEMORY);