browser/devtools/webconsole/test/browser_webconsole_output_copy_newlines.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 // Test that multiple messages are copied into the clipboard and that they are
     5 // separated by new lines. See bug 916997.
     7 function test()
     8 {
     9   const TEST_URI = "data:text/html;charset=utf8,<p>hello world, bug 916997";
    10   let clipboardValue = "";
    12   addTab(TEST_URI);
    13   browser.addEventListener("load", function onLoad() {
    14     browser.removeEventListener("load", onLoad, true);
    15     openConsole(null, consoleOpened);
    16   }, true);
    18   function consoleOpened(hud)
    19   {
    20     hud.jsterm.clearOutput();
    22     let controller = top.document.commandDispatcher.
    23                      getControllerForCommand("cmd_copy");
    24     is(controller.isCommandEnabled("cmd_copy"), false, "cmd_copy is disabled");
    26     content.console.log("Hello world! bug916997a");
    27     content.console.log("Hello world 2! bug916997b");
    29     waitForMessages({
    30       webconsole: hud,
    31       messages: [{
    32         text: "Hello world! bug916997a",
    33         category: CATEGORY_WEBDEV,
    34         severity: SEVERITY_LOG,
    35       }, {
    36         text: "Hello world 2! bug916997b",
    37         category: CATEGORY_WEBDEV,
    38         severity: SEVERITY_LOG,
    39       }],
    40     }).then(() => {
    41       hud.ui.output.selectAllMessages();
    42       hud.outputNode.focus();
    44       goUpdateCommand("cmd_copy");
    45       controller = top.document.commandDispatcher.getControllerForCommand("cmd_copy");
    46       is(controller.isCommandEnabled("cmd_copy"), true, "cmd_copy is enabled");
    48       let selection = hud.iframeWindow.getSelection() + "";
    49       info("selection '" + selection + "'");
    50       waitForClipboard((str) => {
    51           clipboardValue = str;
    52           return str.indexOf("bug916997a") > -1 && str.indexOf("bug916997b") > -1;
    53         },
    54         () => { goDoCommand("cmd_copy"); },
    55         checkClipboard.bind(null, hud),
    56         () => {
    57           info("last clipboard value: '" + clipboardValue + "'");
    58           finishTest();
    59         });
    60     });
    61   }
    63   function checkClipboard(hud)
    64   {
    65     info("clipboard value '" + clipboardValue + "'");
    66     let lines = clipboardValue.trim().split("\n");
    67     is(hud.outputNode.children.length, 2, "number of messages");
    68     is(lines.length, hud.outputNode.children.length, "number of lines");
    69     isnot(lines[0].indexOf("bug916997a"), -1,
    70           "first message text includes 'bug916997a'");
    71     isnot(lines[1].indexOf("bug916997b"), -1,
    72           "second message text includes 'bug916997b'");
    73     is(lines[0].indexOf("bug916997b"), -1,
    74        "first message text does not include 'bug916997b'");
    75     finishTest();
    76   }
    77 }

mercurial