browser/devtools/webconsole/test/browser_webconsole_cd_iframe.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 the cd() jsterm helper function works as expected. See bug 609872.
     6 function test() {
     7   let hud;
     9   const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-bug-609872-cd-iframe-parent.html";
    11   const parentMessages = [{
    12     name: "document.title in parent iframe",
    13     text: "bug 609872 - iframe parent",
    14     category: CATEGORY_OUTPUT,
    15   }, {
    16     name: "paragraph content",
    17     text: "p: test for bug 609872 - iframe parent",
    18     category: CATEGORY_OUTPUT,
    19   }, {
    20     name: "object content",
    21     text: "obj: parent!",
    22     category: CATEGORY_OUTPUT,
    23   }];
    25   const childMessages = [{
    26     name: "document.title in child iframe",
    27     text: "bug 609872 - iframe child",
    28     category: CATEGORY_OUTPUT,
    29   }, {
    30     name: "paragraph content",
    31     text: "p: test for bug 609872 - iframe child",
    32     category: CATEGORY_OUTPUT,
    33   }, {
    34     name: "object content",
    35     text: "obj: child!",
    36     category: CATEGORY_OUTPUT,
    37   }];
    39   Task.spawn(runner).then(finishTest);
    41   function* runner() {
    42     const {tab} = yield loadTab(TEST_URI);
    43     hud = yield openConsole(tab);
    45     executeWindowTest();
    47     yield waitForMessages({ webconsole: hud, messages: parentMessages });
    49     info("cd() into the iframe using a selector");
    50     hud.jsterm.clearOutput();
    51     hud.jsterm.execute("cd('iframe')");
    52     executeWindowTest();
    54     yield waitForMessages({ webconsole: hud, messages: childMessages });
    56     info("cd() out of the iframe, reset to default window");
    57     hud.jsterm.clearOutput();
    58     hud.jsterm.execute("cd()");
    59     executeWindowTest();
    61     yield waitForMessages({ webconsole: hud, messages: parentMessages });
    63     info("call cd() with unexpected arguments");
    64     hud.jsterm.clearOutput();
    65     hud.jsterm.execute("cd(document)");
    67     yield waitForMessages({
    68       webconsole: hud,
    69       messages: [{
    70         text: "Cannot cd()",
    71         category: CATEGORY_OUTPUT,
    72         severity: SEVERITY_ERROR,
    73       }],
    74     });
    76     hud.jsterm.clearOutput();
    77     hud.jsterm.execute("cd('p')");
    79     yield waitForMessages({
    80       webconsole: hud,
    81       messages: [{
    82         text: "Cannot cd()",
    83         category: CATEGORY_OUTPUT,
    84         severity: SEVERITY_ERROR,
    85       }],
    86     });
    88     info("cd() into the iframe using an iframe DOM element");
    89     hud.jsterm.clearOutput();
    90     hud.jsterm.execute("cd($('iframe'))");
    91     executeWindowTest();
    93     yield waitForMessages({ webconsole: hud, messages: childMessages });
    95     info("cd(window.parent)");
    96     hud.jsterm.clearOutput();
    97     hud.jsterm.execute("cd(window.parent)");
    98     executeWindowTest();
   100     yield waitForMessages({ webconsole: hud, messages: parentMessages });
   102     yield closeConsole(tab);
   103   }
   105   function executeWindowTest() {
   106     hud.jsterm.execute("document.title");
   107     hud.jsterm.execute("'p: ' + document.querySelector('p').textContent");
   108     hud.jsterm.execute("'obj: ' + window.foobarBug609872");
   109   }
   110 }

mercurial