Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* |
michael@0 | 2 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | // Test that makes sure messages are not considered repeated when console.log() |
michael@0 | 7 | // is invoked with different objects, see bug 865288. |
michael@0 | 8 | |
michael@0 | 9 | const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-repeated-messages.html"; |
michael@0 | 10 | |
michael@0 | 11 | let hud = null; |
michael@0 | 12 | |
michael@0 | 13 | function test() { |
michael@0 | 14 | addTab(TEST_URI); |
michael@0 | 15 | browser.addEventListener("load", function onLoad() { |
michael@0 | 16 | browser.removeEventListener("load", onLoad, true); |
michael@0 | 17 | openConsole(null, consoleOpened); |
michael@0 | 18 | }, true); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | function consoleOpened(aHud) { |
michael@0 | 22 | hud = aHud; |
michael@0 | 23 | |
michael@0 | 24 | // Check that css warnings are not coalesced if they come from different lines. |
michael@0 | 25 | info("waiting for 3 console.log objects"); |
michael@0 | 26 | |
michael@0 | 27 | hud.jsterm.clearOutput(true); |
michael@0 | 28 | content.wrappedJSObject.testConsoleObjects(); |
michael@0 | 29 | |
michael@0 | 30 | waitForMessages({ |
michael@0 | 31 | webconsole: hud, |
michael@0 | 32 | messages: [{ |
michael@0 | 33 | name: "3 console.log messages", |
michael@0 | 34 | text: "abba", |
michael@0 | 35 | category: CATEGORY_WEBDEV, |
michael@0 | 36 | severity: SEVERITY_LOG, |
michael@0 | 37 | count: 3, |
michael@0 | 38 | repeats: 1, |
michael@0 | 39 | objects: true, |
michael@0 | 40 | }], |
michael@0 | 41 | }).then(checkMessages); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | function checkMessages([result]) |
michael@0 | 45 | { |
michael@0 | 46 | let msgs = [...result.matched]; |
michael@0 | 47 | is(msgs.length, 3, "3 message elements"); |
michael@0 | 48 | let m = -1; |
michael@0 | 49 | |
michael@0 | 50 | function nextMessage() |
michael@0 | 51 | { |
michael@0 | 52 | let msg = msgs[++m]; |
michael@0 | 53 | if (msg) { |
michael@0 | 54 | ok(msg, "message element #" + m); |
michael@0 | 55 | |
michael@0 | 56 | let clickable = msg.querySelector(".message-body a"); |
michael@0 | 57 | ok(clickable, "clickable object #" + m); |
michael@0 | 58 | |
michael@0 | 59 | msg.scrollIntoView(false); |
michael@0 | 60 | clickObject(clickable); |
michael@0 | 61 | } |
michael@0 | 62 | else { |
michael@0 | 63 | finishTest(); |
michael@0 | 64 | } |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | nextMessage(); |
michael@0 | 68 | |
michael@0 | 69 | function clickObject(aObject) |
michael@0 | 70 | { |
michael@0 | 71 | hud.jsterm.once("variablesview-fetched", onObjectFetch); |
michael@0 | 72 | EventUtils.synthesizeMouse(aObject, 2, 2, {}, hud.iframeWindow); |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | function onObjectFetch(aEvent, aVar) |
michael@0 | 76 | { |
michael@0 | 77 | findVariableViewProperties(aVar, [ |
michael@0 | 78 | { name: "id", value: "abba" + m }, |
michael@0 | 79 | ], { webconsole: hud }).then(nextMessage); |
michael@0 | 80 | } |
michael@0 | 81 | } |