browser/devtools/styleinspector/test/browser_computedview_matched-selectors_02.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 // Tests for matched selector texts in the computed view
michael@0 8
michael@0 9 let test = asyncTest(function*() {
michael@0 10 yield addTab("data:text/html,<div style='color:blue;'></div>");
michael@0 11
michael@0 12 info("Opening the computed view");
michael@0 13 let {toolbox, inspector, view} = yield openComputedView();
michael@0 14
michael@0 15 info("Selecting the test node");
michael@0 16 yield selectNode("div", inspector);
michael@0 17
michael@0 18 info("Checking the color property view");
michael@0 19 let propertyView = getPropertyView(view, "color");
michael@0 20 ok(propertyView, "found PropertyView for color");
michael@0 21 is(propertyView.hasMatchedSelectors, true, "hasMatchedSelectors is true");
michael@0 22
michael@0 23 info("Expanding the matched selectors");
michael@0 24 propertyView.matchedExpanded = true;
michael@0 25 yield propertyView.refreshMatchedSelectors();
michael@0 26
michael@0 27 let span = propertyView.matchedSelectorsContainer.querySelector("span.rule-text");
michael@0 28 ok(span, "Found the first table row");
michael@0 29
michael@0 30 let selector = propertyView.matchedSelectorViews[0];
michael@0 31 ok(selector, "Found the first matched selector view");
michael@0 32 });
michael@0 33
michael@0 34 function getPropertyView(computedView, name) {
michael@0 35 let propertyView = null;
michael@0 36 computedView.propertyViews.some(function(view) {
michael@0 37 if (view.name == name) {
michael@0 38 propertyView = view;
michael@0 39 return true;
michael@0 40 }
michael@0 41 return false;
michael@0 42 });
michael@0 43 return propertyView;
michael@0 44 }

mercurial