browser/devtools/inspector/test/browser_inspector_pseudoClass_menu.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 function test() {
michael@0 5
michael@0 6 let DOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
michael@0 7
michael@0 8 let pseudos = ["hover", "active", "focus"];
michael@0 9
michael@0 10 let doc;
michael@0 11 let div;
michael@0 12 let menu;
michael@0 13 let inspector;
michael@0 14
michael@0 15 waitForExplicitFinish();
michael@0 16 ignoreAllUncaughtExceptions();
michael@0 17 gBrowser.selectedTab = gBrowser.addTab();
michael@0 18 gBrowser.selectedBrowser.addEventListener("load", function() {
michael@0 19 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
michael@0 20 doc = content.document;
michael@0 21 waitForFocus(createDocument, content);
michael@0 22 }, true);
michael@0 23
michael@0 24 content.location = "data:text/html,pseudo-class lock node menu tests";
michael@0 25
michael@0 26 function createDocument()
michael@0 27 {
michael@0 28 div = doc.createElement("div");
michael@0 29 div.textContent = "test div";
michael@0 30
michael@0 31 doc.body.appendChild(div);
michael@0 32
michael@0 33 openInspector(selectNode);
michael@0 34 }
michael@0 35
michael@0 36 function selectNode(aInspector)
michael@0 37 {
michael@0 38 inspector = aInspector;
michael@0 39 inspector.selection.setNode(div);
michael@0 40 inspector.once("inspector-updated", performTests);
michael@0 41 }
michael@0 42
michael@0 43 function performTests()
michael@0 44 {
michael@0 45 menu = inspector.panelDoc.getElementById("inspector-node-popup");
michael@0 46 menu.addEventListener("popupshowing", testMenuItems, true);
michael@0 47 menu.openPopup();
michael@0 48 }
michael@0 49
michael@0 50 function testMenuItems()
michael@0 51 {
michael@0 52 menu.removeEventListener("popupshowing", testMenuItems, true);
michael@0 53
michael@0 54 var tryNext = () => {
michael@0 55 if (pseudos.length === 0) {
michael@0 56 finishUp();
michael@0 57 return;
michael@0 58 }
michael@0 59 let pseudo = pseudos.shift();
michael@0 60
michael@0 61 let menuitem = inspector.panelDoc.getElementById("node-menu-pseudo-" + pseudo);
michael@0 62 ok(menuitem, ":" + pseudo + " menuitem exists");
michael@0 63
michael@0 64 menuitem.doCommand();
michael@0 65 inspector.selection.once("pseudoclass", () => {
michael@0 66 is(DOMUtils.hasPseudoClassLock(div, ":" + pseudo), true,
michael@0 67 "pseudo-class lock has been applied");
michael@0 68 tryNext();
michael@0 69 });
michael@0 70 }
michael@0 71 tryNext();
michael@0 72 }
michael@0 73
michael@0 74 function finishUp()
michael@0 75 {
michael@0 76 gBrowser.removeCurrentTab();
michael@0 77 finish();
michael@0 78 }
michael@0 79 }

mercurial