browser/devtools/styleinspector/test/browser_computedview_matched-selectors-toggle.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 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
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 "use strict";
michael@0 6
michael@0 7 // Test that the computed view properties can be expanded and collapsed with
michael@0 8 // either the twisty or by dbl-clicking on the container
michael@0 9
michael@0 10 const TEST_URL = "data:text/html," + encodeURIComponent([
michael@0 11 '<html>' +
michael@0 12 '<head>' +
michael@0 13 ' <title>Computed view toggling test</title>',
michael@0 14 ' <style type="text/css"> ',
michael@0 15 ' html { color: #000000; font-size: 15pt; } ',
michael@0 16 ' h1 { color: red; } ',
michael@0 17 ' </style>',
michael@0 18 '</head>',
michael@0 19 '<body>',
michael@0 20 ' <h1>Some header text</h1>',
michael@0 21 '</body>',
michael@0 22 '</html>'
michael@0 23 ].join("\n"));
michael@0 24
michael@0 25 let test = asyncTest(function*() {
michael@0 26 yield addTab(TEST_URL);
michael@0 27 let {toolbox, inspector, view} = yield openComputedView();
michael@0 28
michael@0 29 info("Selecting the test node");
michael@0 30 yield selectNode("h1", inspector);
michael@0 31
michael@0 32 yield testExpandOnTwistyClick(view, inspector);
michael@0 33 yield testCollapseOnTwistyClick(view, inspector);
michael@0 34 yield testExpandOnDblClick(view, inspector);
michael@0 35 yield testCollapseOnDblClick(view, inspector);
michael@0 36 });
michael@0 37
michael@0 38 function* testExpandOnTwistyClick({styleDocument, styleWindow}, inspector) {
michael@0 39 info("Testing that a property expands on twisty click");
michael@0 40
michael@0 41 info("Getting twisty element");
michael@0 42 let twisty = styleDocument.querySelector(".expandable");
michael@0 43 ok(twisty, "Twisty found");
michael@0 44
michael@0 45 let onExpand = inspector.once("computed-view-property-expanded");
michael@0 46 info("Clicking on the twisty element");
michael@0 47 twisty.click();
michael@0 48
michael@0 49 yield onExpand;
michael@0 50
michael@0 51 // Expanded means the matchedselectors div is not empty
michael@0 52 let div = styleDocument.querySelector(".property-content .matchedselectors");
michael@0 53 ok(div.childNodes.length > 0, "Matched selectors are expanded on twisty click");
michael@0 54 }
michael@0 55
michael@0 56 function* testCollapseOnTwistyClick({styleDocument, styleWindow}, inspector) {
michael@0 57 info("Testing that a property collapses on twisty click");
michael@0 58
michael@0 59 info("Getting twisty element");
michael@0 60 let twisty = styleDocument.querySelector(".expandable");
michael@0 61 ok(twisty, "Twisty found");
michael@0 62
michael@0 63 let onCollapse = inspector.once("computed-view-property-collapsed");
michael@0 64 info("Clicking on the twisty element");
michael@0 65 twisty.click();
michael@0 66
michael@0 67 yield onCollapse;
michael@0 68
michael@0 69 // Collapsed means the matchedselectors div is empty
michael@0 70 let div = styleDocument.querySelector(".property-content .matchedselectors");
michael@0 71 ok(div.childNodes.length === 0, "Matched selectors are collapsed on twisty click");
michael@0 72 }
michael@0 73
michael@0 74 function* testExpandOnDblClick({styleDocument, styleWindow}, inspector) {
michael@0 75 info("Testing that a property expands on container dbl-click");
michael@0 76
michael@0 77 info("Getting computed property container");
michael@0 78 let container = styleDocument.querySelector(".property-view");
michael@0 79 ok(container, "Container found");
michael@0 80
michael@0 81 let onExpand = inspector.once("computed-view-property-expanded");
michael@0 82 info("Dbl-clicking on the container");
michael@0 83 EventUtils.synthesizeMouseAtCenter(container, {clickCount: 2}, styleWindow);
michael@0 84
michael@0 85 yield onExpand;
michael@0 86
michael@0 87 // Expanded means the matchedselectors div is not empty
michael@0 88 let div = styleDocument.querySelector(".property-content .matchedselectors");
michael@0 89 ok(div.childNodes.length > 0, "Matched selectors are expanded on dblclick");
michael@0 90 }
michael@0 91
michael@0 92 function* testCollapseOnDblClick({styleDocument, styleWindow}, inspector) {
michael@0 93 info("Testing that a property collapses on container dbl-click");
michael@0 94
michael@0 95 info("Getting computed property container");
michael@0 96 let container = styleDocument.querySelector(".property-view");
michael@0 97 ok(container, "Container found");
michael@0 98
michael@0 99 let onCollapse = inspector.once("computed-view-property-collapsed");
michael@0 100 info("Dbl-clicking on the container");
michael@0 101 EventUtils.synthesizeMouseAtCenter(container, {clickCount: 2}, styleWindow);
michael@0 102
michael@0 103 yield onCollapse;
michael@0 104
michael@0 105 // Collapsed means the matchedselectors div is empty
michael@0 106 let div = styleDocument.querySelector(".property-content .matchedselectors");
michael@0 107 ok(div.childNodes.length === 0, "Matched selectors are collapsed on dblclick");
michael@0 108 }

mercurial