browser/devtools/webconsole/test/browser_console_log_inspectable_object.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_log_inspectable_object.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +/* vim:set ts=2 sw=2 sts=2 et: */
     1.5 +/* Any copyright is dedicated to the Public Domain.
     1.6 + * http://creativecommons.org/publicdomain/zero/1.0/ */
     1.7 +
     1.8 +// Test that objects given to console.log() are inspectable.
     1.9 +
    1.10 +function test()
    1.11 +{
    1.12 +  waitForExplicitFinish();
    1.13 +
    1.14 +  addTab("data:text/html;charset=utf8,test for bug 676722 - inspectable objects for window.console");
    1.15 +
    1.16 +  gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
    1.17 +    gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
    1.18 +    openConsole(null, performTest);
    1.19 +  }, true);
    1.20 +}
    1.21 +
    1.22 +function performTest(hud)
    1.23 +{
    1.24 +  hud.jsterm.clearOutput(true);
    1.25 +
    1.26 +  hud.jsterm.execute("myObj = {abba: 'omgBug676722'}");
    1.27 +  hud.jsterm.execute("console.log('fooBug676722', myObj)");
    1.28 +
    1.29 +  waitForMessages({
    1.30 +    webconsole: hud,
    1.31 +    messages: [{
    1.32 +      text: "fooBug676722",
    1.33 +      category: CATEGORY_WEBDEV,
    1.34 +      severity: SEVERITY_LOG,
    1.35 +      objects: true,
    1.36 +    }],
    1.37 +  }).then(([result]) => {
    1.38 +    let msg = [...result.matched][0];
    1.39 +    ok(msg, "message element");
    1.40 +    let body = msg.querySelector(".message-body");
    1.41 +    ok(body, "message body");
    1.42 +    let clickable = result.clickableElements[0];
    1.43 +    ok(clickable, "the console.log() object anchor was found");
    1.44 +    ok(body.textContent.contains('{ abba: "omgBug676722" }'),
    1.45 +       "clickable node content is correct");
    1.46 +
    1.47 +    hud.jsterm.once("variablesview-fetched",
    1.48 +      (aEvent, aVar) => {
    1.49 +        ok(aVar, "object inspector opened on click");
    1.50 +
    1.51 +        findVariableViewProperties(aVar, [{
    1.52 +          name: "abba",
    1.53 +          value: "omgBug676722",
    1.54 +        }], { webconsole: hud }).then(finishTest);
    1.55 +      });
    1.56 +
    1.57 +    executeSoon(function() {
    1.58 +      EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
    1.59 +    });
    1.60 +  });
    1.61 +}

mercurial