gecko-dev/layout/base/tests/test_bug396024.html
Daniel Holbert 192f557403 (No code changes) Change a bunch of non-executable files in layout/ to have non-executable mode.
Filetypes changed: .cpp .gif .h .html .list .png .svg .x-ccmap .xbl .xhtml .xul
2008-07-11 11:54:06 -07:00

119 lines
5.0 KiB
HTML

<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=396024
-->
<head>
<title>Test for Bug 396024</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=396024">Mozilla Bug 396024</a>
<pre id="test">
<script class="testbody" type="text/javascript">
var gWbp;
function printpreview() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalPreferencesRead UniversalPreferencesWrite UniversalXPConnect');
gWbp = window.frames[0].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
var listener = {
onLocationChange: function(webProgress, request, location) { },
onProgressChange: function(webProgress, request, curSelfProgress,
maxSelfProgress, curTotalProgress,
maxTotalProgress) { },
onSecurityChange: function(webProgress, request, state) { },
onStateChange: function(webProgress, request, stateFlags, status) { },
onStatusChange: function(webProgress, request, status, message) { },
QueryInterface: function(iid) {
if (iid.equals(Components.interfaces.nsIWebProgessListener) ||
iid.equals(Components.interfaces.nsISupportsWeakReference))
return this;
throw Components.results.NS_NOINTERFACE;
}
}
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
prefs.setBoolPref('print.show_print_progress', false);
//XXX I would have thought this would work, instead I'm forced to use prefs service
gWbp.globalPrintSettings.showPrintProgress = false;
gWbp.printPreview(gWbp.globalPrintSettings, null, listener);
prefs.clearUserPref('print.show_print_progress');
}
function exitprintpreview() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalPreferencesRead UniversalPreferencesWrite UniversalXPConnect');
window.frames[0].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint).exitPrintPreview();
}
function run()
{
/** Test for Bug 396024 **/
netscape.security.PrivilegeManager.enablePrivilege('UniversalPreferencesRead UniversalPreferencesWrite UniversalXPConnect');
var printService = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
.getService(Components.interfaces.nsIPrintSettingsService);
try {
var printerEnumerator = Components.classes["@mozilla.org/gfx/printerenumerator;1"]
.getService(Components.interfaces.nsIPrinterEnumerator);
} catch(e) {
//don't try to test on Mac, since the print preview code doesn't work there
SimpleTest.finish();
return;
}
if (printService.defaultPrinterName != '') {
window.frames[0].frameElement.removeAttribute('onload');
printpreview();
ok(gWbp.doingPrintPreview, "Should be doing print preview");
exitprintpreview();
ok(!gWbp.doingPrintPreview, "Should not be doing print preview anymore1");
printpreview();
setTimeout(run2, 0)
} else {
todo(false, "No printer seems installed on this machine, that is necessary for this test");
SimpleTest.finish();
}
}
function run2() {
window.frames[0].frameElement.setAttribute('onload', 'setTimeout(run3, 0)');
window.frames[0].location.reload();
}
function run3() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalPreferencesRead UniversalPreferencesWrite UniversalXPConnect');
gWbp = window.frames[0].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
ok(!gWbp.doingPrintPreview, "Should not be doing print preview anymore2");
window.frames[0].frameElement.removeAttribute('onload');
printpreview();
setTimeout(run4, 0);
}
function run4() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalPreferencesRead UniversalPreferencesWrite UniversalXPConnect');
var x = window.frames[0].frameElement.parentNode.removeChild(window.frames[0].frameElement);
x.setAttribute('onload', 'setTimeout(run5, 0)');
document.body.offsetHeight;
document.body.appendChild(x);
gWbp = window.frames[0].QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
ok(!gWbp.doingPrintPreview, "Should not be doing print preview anymore3");
}
function run5() {
//XXX this shouldn't be necessary, see bug 405555
printpreview();
exitprintpreview();
SimpleTest.finish(); //should not have crashed after all of this
}
</script>
<iframe onload="SimpleTest.waitForExplicitFinish(); setTimeout(run, 0)" src="data:text/html;charset=utf-8,"></iframe>
</pre>
</body>
</html>