browser/devtools/webconsole/test/browser_webconsole_execution_scope.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/webconsole/test/browser_webconsole_execution_scope.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,41 @@
     1.4 +/* vim:set ts=2 sw=2 sts=2 et: */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +// Tests that commands run by the user are executed in content space.
    1.10 +
    1.11 +const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
    1.12 +
    1.13 +function test() {
    1.14 +  addTab(TEST_URI);
    1.15 +  browser.addEventListener("load", function onLoad() {
    1.16 +    browser.removeEventListener("load", onLoad, true);
    1.17 +    openConsole(null, testExecutionScope);
    1.18 +  }, true);
    1.19 +}
    1.20 +
    1.21 +function testExecutionScope(hud) {
    1.22 +  let jsterm = hud.jsterm;
    1.23 +
    1.24 +  jsterm.clearOutput();
    1.25 +  jsterm.execute("window.location.href;");
    1.26 +  waitForMessages({
    1.27 +    webconsole: hud,
    1.28 +    messages: [{
    1.29 +      text: "window.location.href;",
    1.30 +      category: CATEGORY_INPUT,
    1.31 +    },
    1.32 +    {
    1.33 +      text: TEST_URI,
    1.34 +      category: CATEGORY_OUTPUT,
    1.35 +    }],
    1.36 +  }).then(([input, output]) => {
    1.37 +    let inputNode = [...input.matched][0];
    1.38 +    let outputNode = [...output.matched][0];
    1.39 +    is(inputNode.getAttribute("category"), "input", "input node category is correct");
    1.40 +    is(outputNode.getAttribute("category"), "output", "output node category is correct");
    1.41 +    finishTest();
    1.42 +  });
    1.43 +}
    1.44 +

mercurial