Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 function test() {
2 waitForExplicitFinish();
4 ok(!gInPrintPreviewMode,
5 "Should NOT be in print preview mode at starting this tests");
6 // Skip access key test on platforms which don't support access key.
7 if (!/Win|Linux/.test(navigator.platform)) {
8 openPrintPreview(testClosePrintPreviewWithEscKey);
9 } else {
10 openPrintPreview(testClosePrintPreviewWithAccessKey);
11 }
12 }
14 function testClosePrintPreviewWithAccessKey() {
15 EventUtils.synthesizeKey("c", { altKey: true });
16 checkPrintPreviewClosed(function (aSucceeded) {
17 ok(aSucceeded,
18 "print preview mode should be finished by access key");
19 openPrintPreview(testClosePrintPreviewWithEscKey);
20 });
21 }
23 function testClosePrintPreviewWithEscKey() {
24 EventUtils.synthesizeKey("VK_ESCAPE", {});
25 checkPrintPreviewClosed(function (aSucceeded) {
26 ok(aSucceeded,
27 "print preview mode should be finished by Esc key press");
28 openPrintPreview(testClosePrintPreviewWithClosingWindowShortcutKey);
29 });
30 }
32 function testClosePrintPreviewWithClosingWindowShortcutKey() {
33 EventUtils.synthesizeKey("w", { accelKey: true });
34 checkPrintPreviewClosed(function (aSucceeded) {
35 ok(aSucceeded,
36 "print preview mode should be finished by closing window shortcut key");
37 finish();
38 });
39 }
41 function openPrintPreview(aCallback) {
42 document.getElementById("cmd_printPreview").doCommand();
43 executeSoon(function () {
44 if (gInPrintPreviewMode) {
45 executeSoon(aCallback);
46 return;
47 }
48 executeSoon(arguments.callee);
49 });
50 }
52 function checkPrintPreviewClosed(aCallback) {
53 let count = 0;
54 executeSoon(function () {
55 if (!gInPrintPreviewMode) {
56 executeSoon(function () { aCallback(count < 1000); });
57 return;
58 }
59 if (++count == 1000) {
60 // The test might fail.
61 PrintUtils.exitPrintPreview();
62 }
63 executeSoon(arguments.callee);
64 });
65 }