browser/devtools/webconsole/test/browser_webconsole_console_api_stackframe.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 "use strict";
     6 // Test that the console API messages for console.error()/exception()/assert()
     7 // include a stackframe. See bug 920116.
     9 function test() {
    10   let hud;
    12   const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console-api-stackframe.html";
    13   const TEST_FILE = TEST_URI.substr(TEST_URI.lastIndexOf("/"));
    15   Task.spawn(runner).then(finishTest);
    17   function* runner() {
    18     const {tab} = yield loadTab(TEST_URI);
    19     hud = yield openConsole(tab);
    21     const stack = [{
    22       file: TEST_FILE,
    23       fn: "thirdCall",
    24       line: /\b2[123]\b/, // 21,22,23
    25     }, {
    26       file: TEST_FILE,
    27       fn: "secondCall",
    28       line: 16,
    29     }, {
    30       file: TEST_FILE,
    31       fn: "firstCall",
    32       line: 12,
    33     }];
    35     let results = yield waitForMessages({
    36       webconsole: hud,
    37       messages: [{
    38         text: "foo-log",
    39         category: CATEGORY_WEBDEV,
    40         severity: SEVERITY_LOG,
    41         collapsible: false,
    42       }, {
    43         text: "foo-error",
    44         category: CATEGORY_WEBDEV,
    45         severity: SEVERITY_ERROR,
    46         collapsible: true,
    47         stacktrace: stack,
    48       }, {
    49         text: "foo-exception",
    50         category: CATEGORY_WEBDEV,
    51         severity: SEVERITY_ERROR,
    52         collapsible: true,
    53         stacktrace: stack,
    54       }, {
    55         text: "foo-assert",
    56         category: CATEGORY_WEBDEV,
    57         severity: SEVERITY_ERROR,
    58         collapsible: true,
    59         stacktrace: stack,
    60       }],
    61     });
    63     let elem = [...results[1].matched][0];
    64     ok(elem, "message element");
    66     let msg = elem._messageObject;
    67     ok(msg, "message object");
    69     ok(msg.collapsed, "message is collapsed");
    71     msg.toggleDetails();
    73     ok(!msg.collapsed, "message is not collapsed");
    75     msg.toggleDetails();
    77     ok(msg.collapsed, "message is collapsed");
    79     yield closeConsole(tab);
    80   }
    81 }

mercurial