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