browser/devtools/webconsole/test/browser_console_navigation_marker.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/webconsole/test/browser_console_navigation_marker.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,81 @@
     1.4 +/*
     1.5 + * Any copyright is dedicated to the Public Domain.
     1.6 + * http://creativecommons.org/publicdomain/zero/1.0/
     1.7 + */
     1.8 +
     1.9 +// Check that the navigation marker shows on page reload - bug 793996.
    1.10 +
    1.11 +function test()
    1.12 +{
    1.13 +  const PREF = "devtools.webconsole.persistlog";
    1.14 +  const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
    1.15 +  let hud = null;
    1.16 +  let Messages = require("devtools/webconsole/console-output").Messages;
    1.17 +
    1.18 +  Services.prefs.setBoolPref(PREF, true);
    1.19 +  registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
    1.20 +
    1.21 +  addTab(TEST_URI);
    1.22 +
    1.23 +  browser.addEventListener("load", function onLoad() {
    1.24 +    browser.removeEventListener("load", onLoad, true);
    1.25 +    openConsole(null, consoleOpened);
    1.26 +  }, true);
    1.27 +
    1.28 +  function consoleOpened(aHud)
    1.29 +  {
    1.30 +    hud = aHud;
    1.31 +    ok(hud, "Web Console opened");
    1.32 +
    1.33 +    hud.jsterm.clearOutput();
    1.34 +    content.console.log("foobarz1");
    1.35 +    waitForMessages({
    1.36 +      webconsole: hud,
    1.37 +      messages: [{
    1.38 +        text: "foobarz1",
    1.39 +        category: CATEGORY_WEBDEV,
    1.40 +        severity: SEVERITY_LOG,
    1.41 +      }],
    1.42 +    }).then(onConsoleMessage);
    1.43 +  }
    1.44 +
    1.45 +  function onConsoleMessage()
    1.46 +  {
    1.47 +    browser.addEventListener("load", onReload, true);
    1.48 +    content.location.reload();
    1.49 +  }
    1.50 +
    1.51 +  function onReload()
    1.52 +  {
    1.53 +    browser.removeEventListener("load", onReload, true);
    1.54 +
    1.55 +    content.console.log("foobarz2");
    1.56 +
    1.57 +    waitForMessages({
    1.58 +      webconsole: hud,
    1.59 +      messages: [{
    1.60 +        name: "page reload",
    1.61 +        text: "test-console.html",
    1.62 +        category: CATEGORY_NETWORK,
    1.63 +        severity: SEVERITY_LOG,
    1.64 +      },
    1.65 +      {
    1.66 +        text: "foobarz2",
    1.67 +        category: CATEGORY_WEBDEV,
    1.68 +        severity: SEVERITY_LOG,
    1.69 +      },
    1.70 +      {
    1.71 +        name: "navigation marker",
    1.72 +        text: "test-console.html",
    1.73 +        type: Messages.NavigationMarker,
    1.74 +      }],
    1.75 +    }).then(onConsoleMessageAfterReload);
    1.76 +  }
    1.77 +
    1.78 +  function onConsoleMessageAfterReload()
    1.79 +  {
    1.80 +    isnot(hud.outputNode.textContent.indexOf("foobarz1"), -1,
    1.81 +          "foobarz1 is still in the output");
    1.82 +    finishTest();
    1.83 +  }
    1.84 +}

mercurial