1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/webconsole/test/browser_bug_865288_repeat_different_objects.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,81 @@ 1.4 +/* 1.5 + * Any copyright is dedicated to the Public Domain. 1.6 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.7 + */ 1.8 + 1.9 +// Test that makes sure messages are not considered repeated when console.log() 1.10 +// is invoked with different objects, see bug 865288. 1.11 + 1.12 +const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-repeated-messages.html"; 1.13 + 1.14 +let hud = null; 1.15 + 1.16 +function test() { 1.17 + addTab(TEST_URI); 1.18 + browser.addEventListener("load", function onLoad() { 1.19 + browser.removeEventListener("load", onLoad, true); 1.20 + openConsole(null, consoleOpened); 1.21 + }, true); 1.22 +} 1.23 + 1.24 +function consoleOpened(aHud) { 1.25 + hud = aHud; 1.26 + 1.27 + // Check that css warnings are not coalesced if they come from different lines. 1.28 + info("waiting for 3 console.log objects"); 1.29 + 1.30 + hud.jsterm.clearOutput(true); 1.31 + content.wrappedJSObject.testConsoleObjects(); 1.32 + 1.33 + waitForMessages({ 1.34 + webconsole: hud, 1.35 + messages: [{ 1.36 + name: "3 console.log messages", 1.37 + text: "abba", 1.38 + category: CATEGORY_WEBDEV, 1.39 + severity: SEVERITY_LOG, 1.40 + count: 3, 1.41 + repeats: 1, 1.42 + objects: true, 1.43 + }], 1.44 + }).then(checkMessages); 1.45 +} 1.46 + 1.47 +function checkMessages([result]) 1.48 +{ 1.49 + let msgs = [...result.matched]; 1.50 + is(msgs.length, 3, "3 message elements"); 1.51 + let m = -1; 1.52 + 1.53 + function nextMessage() 1.54 + { 1.55 + let msg = msgs[++m]; 1.56 + if (msg) { 1.57 + ok(msg, "message element #" + m); 1.58 + 1.59 + let clickable = msg.querySelector(".message-body a"); 1.60 + ok(clickable, "clickable object #" + m); 1.61 + 1.62 + msg.scrollIntoView(false); 1.63 + clickObject(clickable); 1.64 + } 1.65 + else { 1.66 + finishTest(); 1.67 + } 1.68 + } 1.69 + 1.70 + nextMessage(); 1.71 + 1.72 + function clickObject(aObject) 1.73 + { 1.74 + hud.jsterm.once("variablesview-fetched", onObjectFetch); 1.75 + EventUtils.synthesizeMouse(aObject, 2, 2, {}, hud.iframeWindow); 1.76 + } 1.77 + 1.78 + function onObjectFetch(aEvent, aVar) 1.79 + { 1.80 + findVariableViewProperties(aVar, [ 1.81 + { name: "id", value: "abba" + m }, 1.82 + ], { webconsole: hud }).then(nextMessage); 1.83 + } 1.84 +}