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 /*
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
4 *
5 * Contributor(s):
6 * Mihai Șucan <mihai.sucan@gmail.com>
7 */
9 const TEST_URI = "data:text/html;charset=utf-8,Web Console test for bug 613280";
11 function test() {
12 addTab(TEST_URI);
13 browser.addEventListener("load", function onLoad() {
14 browser.removeEventListener("load", onLoad, true);
15 openConsole(null, function(HUD) {
16 content.console.log("foobarBazBug613280");
17 waitForMessages({
18 webconsole: HUD,
19 messages: [{
20 text: "foobarBazBug613280",
21 category: CATEGORY_WEBDEV,
22 severity: SEVERITY_LOG,
23 }],
24 }).then(performTest.bind(null, HUD));
25 });
26 }, true);
27 }
29 function performTest(HUD, [result]) {
30 let msg = [...result.matched][0];
31 let input = HUD.jsterm.inputNode;
32 let selection = getSelection();
33 let contentSelection = content.getSelection();
35 let clipboard_setup = function() {
36 goDoCommand("cmd_copy");
37 };
39 let clipboard_copy_done = function() {
40 finishTest();
41 };
43 // Check if we first need to clear any existing selections.
44 if (selection.rangeCount > 0 || contentSelection.rangeCount > 0 ||
45 input.selectionStart != input.selectionEnd) {
46 if (input.selectionStart != input.selectionEnd) {
47 input.selectionStart = input.selectionEnd = 0;
48 }
50 if (selection.rangeCount > 0) {
51 selection.removeAllRanges();
52 }
54 if (contentSelection.rangeCount > 0) {
55 contentSelection.removeAllRanges();
56 }
58 goUpdateCommand("cmd_copy");
59 }
61 let controller = top.document.commandDispatcher.
62 getControllerForCommand("cmd_copy");
63 is(controller.isCommandEnabled("cmd_copy"), false, "cmd_copy is disabled");
65 HUD.ui.output.selectMessage(msg);
66 HUD.outputNode.focus();
68 goUpdateCommand("cmd_copy");
70 controller = top.document.commandDispatcher.
71 getControllerForCommand("cmd_copy");
72 is(controller.isCommandEnabled("cmd_copy"), true, "cmd_copy is enabled");
74 let selectionText = HUD.iframeWindow.getSelection() + "";
75 isnot(selectionText.indexOf("foobarBazBug613280"), -1,
76 "selection text includes 'foobarBazBug613280'");
78 waitForClipboard((str) => { return str.trim() == selectionText.trim(); },
79 clipboard_setup, clipboard_copy_done, clipboard_copy_done);
80 }