michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html"; michael@0: michael@0: function test() { michael@0: addTab(TEST_URI); michael@0: browser.addEventListener("load", function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: michael@0: openConsole(null, function(hud) { michael@0: content.location.reload(); michael@0: michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [{ michael@0: text: "test-console.html", michael@0: category: CATEGORY_NETWORK, michael@0: severity: SEVERITY_LOG, michael@0: }], michael@0: }).then(performTest); michael@0: }); michael@0: }, true); michael@0: } michael@0: michael@0: function performTest(results) { michael@0: let HUD = HUDService.getHudByWindow(content); michael@0: michael@0: let networkMessage = [...results[0].matched][0]; michael@0: ok(networkMessage, "network message element"); michael@0: michael@0: let networkLink = networkMessage.querySelector(".url"); michael@0: ok(networkLink, "found network message link"); michael@0: michael@0: let popupset = document.getElementById("mainPopupSet"); michael@0: ok(popupset, "found #mainPopupSet"); michael@0: michael@0: let popupsShown = 0; michael@0: let hiddenPopups = 0; michael@0: michael@0: let onpopupshown = function() { michael@0: document.removeEventListener("popupshown", onpopupshown, false); michael@0: popupsShown++; michael@0: michael@0: executeSoon(function() { michael@0: let popups = popupset.querySelectorAll("panel[hudId=" + HUD.hudId + "]"); michael@0: is(popups.length, 1, "found one popup"); michael@0: michael@0: document.addEventListener("popuphidden", onpopuphidden, false); michael@0: michael@0: registerCleanupFunction(function() { michael@0: is(hiddenPopups, 1, "correct number of popups hidden"); michael@0: if (hiddenPopups != 1) { michael@0: document.removeEventListener("popuphidden", onpopuphidden, false); michael@0: } michael@0: }); michael@0: michael@0: executeSoon(closeConsole); michael@0: }); michael@0: }; michael@0: michael@0: let onpopuphidden = function() { michael@0: document.removeEventListener("popuphidden", onpopuphidden, false); michael@0: hiddenPopups++; michael@0: michael@0: executeSoon(function() { michael@0: let popups = popupset.querySelectorAll("panel[hudId=" + HUD.hudId + "]"); michael@0: is(popups.length, 0, "no popups found"); michael@0: michael@0: executeSoon(finishTest); michael@0: }); michael@0: }; michael@0: michael@0: document.addEventListener("popupshown", onpopupshown, false); michael@0: michael@0: registerCleanupFunction(function() { michael@0: is(popupsShown, 1, "correct number of popups shown"); michael@0: if (popupsShown != 1) { michael@0: document.removeEventListener("popupshown", onpopupshown, false); michael@0: } michael@0: }); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, networkLink, HUD.iframeWindow); michael@0: EventUtils.sendMouseEvent({ type: "mouseup" }, networkLink, HUD.iframeWindow); michael@0: EventUtils.sendMouseEvent({ type: "click" }, networkLink, HUD.iframeWindow); michael@0: }