michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: // Test that the console API messages for console.error()/exception()/assert() michael@0: // include a stackframe. See bug 920116. michael@0: michael@0: function test() { michael@0: let hud; michael@0: michael@0: const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console-api-stackframe.html"; michael@0: const TEST_FILE = TEST_URI.substr(TEST_URI.lastIndexOf("/")); michael@0: michael@0: Task.spawn(runner).then(finishTest); michael@0: michael@0: function* runner() { michael@0: const {tab} = yield loadTab(TEST_URI); michael@0: hud = yield openConsole(tab); michael@0: michael@0: const stack = [{ michael@0: file: TEST_FILE, michael@0: fn: "thirdCall", michael@0: line: /\b2[123]\b/, // 21,22,23 michael@0: }, { michael@0: file: TEST_FILE, michael@0: fn: "secondCall", michael@0: line: 16, michael@0: }, { michael@0: file: TEST_FILE, michael@0: fn: "firstCall", michael@0: line: 12, michael@0: }]; michael@0: michael@0: let results = yield waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [{ michael@0: text: "foo-log", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_LOG, michael@0: collapsible: false, michael@0: }, { michael@0: text: "foo-error", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_ERROR, michael@0: collapsible: true, michael@0: stacktrace: stack, michael@0: }, { michael@0: text: "foo-exception", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_ERROR, michael@0: collapsible: true, michael@0: stacktrace: stack, michael@0: }, { michael@0: text: "foo-assert", michael@0: category: CATEGORY_WEBDEV, michael@0: severity: SEVERITY_ERROR, michael@0: collapsible: true, michael@0: stacktrace: stack, michael@0: }], michael@0: }); michael@0: michael@0: let elem = [...results[1].matched][0]; michael@0: ok(elem, "message element"); michael@0: michael@0: let msg = elem._messageObject; michael@0: ok(msg, "message object"); michael@0: michael@0: ok(msg.collapsed, "message is collapsed"); michael@0: michael@0: msg.toggleDetails(); michael@0: michael@0: ok(!msg.collapsed, "message is not collapsed"); michael@0: michael@0: msg.toggleDetails(); michael@0: michael@0: ok(msg.collapsed, "message is collapsed"); michael@0: michael@0: yield closeConsole(tab); michael@0: } michael@0: }