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 | /* vim:set ts=2 sw=2 sts=2 et: */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html"; |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | addTab(TEST_URI); |
michael@0 | 10 | browser.addEventListener("load", function onLoad() { |
michael@0 | 11 | browser.removeEventListener("load", onLoad, true); |
michael@0 | 12 | |
michael@0 | 13 | openConsole(null, function(hud) { |
michael@0 | 14 | content.location.reload(); |
michael@0 | 15 | |
michael@0 | 16 | waitForMessages({ |
michael@0 | 17 | webconsole: hud, |
michael@0 | 18 | messages: [{ |
michael@0 | 19 | text: "test-console.html", |
michael@0 | 20 | category: CATEGORY_NETWORK, |
michael@0 | 21 | severity: SEVERITY_LOG, |
michael@0 | 22 | }], |
michael@0 | 23 | }).then(performTest); |
michael@0 | 24 | }); |
michael@0 | 25 | }, true); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | function performTest(results) { |
michael@0 | 29 | let HUD = HUDService.getHudByWindow(content); |
michael@0 | 30 | |
michael@0 | 31 | let networkMessage = [...results[0].matched][0]; |
michael@0 | 32 | ok(networkMessage, "network message element"); |
michael@0 | 33 | |
michael@0 | 34 | let networkLink = networkMessage.querySelector(".url"); |
michael@0 | 35 | ok(networkLink, "found network message link"); |
michael@0 | 36 | |
michael@0 | 37 | let popupset = document.getElementById("mainPopupSet"); |
michael@0 | 38 | ok(popupset, "found #mainPopupSet"); |
michael@0 | 39 | |
michael@0 | 40 | let popupsShown = 0; |
michael@0 | 41 | let hiddenPopups = 0; |
michael@0 | 42 | |
michael@0 | 43 | let onpopupshown = function() { |
michael@0 | 44 | document.removeEventListener("popupshown", onpopupshown, false); |
michael@0 | 45 | popupsShown++; |
michael@0 | 46 | |
michael@0 | 47 | executeSoon(function() { |
michael@0 | 48 | let popups = popupset.querySelectorAll("panel[hudId=" + HUD.hudId + "]"); |
michael@0 | 49 | is(popups.length, 1, "found one popup"); |
michael@0 | 50 | |
michael@0 | 51 | document.addEventListener("popuphidden", onpopuphidden, false); |
michael@0 | 52 | |
michael@0 | 53 | registerCleanupFunction(function() { |
michael@0 | 54 | is(hiddenPopups, 1, "correct number of popups hidden"); |
michael@0 | 55 | if (hiddenPopups != 1) { |
michael@0 | 56 | document.removeEventListener("popuphidden", onpopuphidden, false); |
michael@0 | 57 | } |
michael@0 | 58 | }); |
michael@0 | 59 | |
michael@0 | 60 | executeSoon(closeConsole); |
michael@0 | 61 | }); |
michael@0 | 62 | }; |
michael@0 | 63 | |
michael@0 | 64 | let onpopuphidden = function() { |
michael@0 | 65 | document.removeEventListener("popuphidden", onpopuphidden, false); |
michael@0 | 66 | hiddenPopups++; |
michael@0 | 67 | |
michael@0 | 68 | executeSoon(function() { |
michael@0 | 69 | let popups = popupset.querySelectorAll("panel[hudId=" + HUD.hudId + "]"); |
michael@0 | 70 | is(popups.length, 0, "no popups found"); |
michael@0 | 71 | |
michael@0 | 72 | executeSoon(finishTest); |
michael@0 | 73 | }); |
michael@0 | 74 | }; |
michael@0 | 75 | |
michael@0 | 76 | document.addEventListener("popupshown", onpopupshown, false); |
michael@0 | 77 | |
michael@0 | 78 | registerCleanupFunction(function() { |
michael@0 | 79 | is(popupsShown, 1, "correct number of popups shown"); |
michael@0 | 80 | if (popupsShown != 1) { |
michael@0 | 81 | document.removeEventListener("popupshown", onpopupshown, false); |
michael@0 | 82 | } |
michael@0 | 83 | }); |
michael@0 | 84 | |
michael@0 | 85 | EventUtils.sendMouseEvent({ type: "mousedown" }, networkLink, HUD.iframeWindow); |
michael@0 | 86 | EventUtils.sendMouseEvent({ type: "mouseup" }, networkLink, HUD.iframeWindow); |
michael@0 | 87 | EventUtils.sendMouseEvent({ type: "click" }, networkLink, HUD.iframeWindow); |
michael@0 | 88 | } |