browser/devtools/styleinspector/test/browser_computedview_matched-selectors_02.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/styleinspector/test/browser_computedview_matched-selectors_02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,44 @@
     1.4 +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
     1.5 +/* Any copyright is dedicated to the Public Domain.
     1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */
     1.7 +
     1.8 +"use strict";
     1.9 +
    1.10 +// Tests for matched selector texts in the computed view
    1.11 +
    1.12 +let test = asyncTest(function*() {
    1.13 +  yield addTab("data:text/html,<div style='color:blue;'></div>");
    1.14 +
    1.15 +  info("Opening the computed view");
    1.16 +  let {toolbox, inspector, view} = yield openComputedView();
    1.17 +
    1.18 +  info("Selecting the test node");
    1.19 +  yield selectNode("div", inspector);
    1.20 +
    1.21 +  info("Checking the color property view");
    1.22 +  let propertyView = getPropertyView(view, "color");
    1.23 +  ok(propertyView, "found PropertyView for color");
    1.24 +  is(propertyView.hasMatchedSelectors, true, "hasMatchedSelectors is true");
    1.25 +
    1.26 +  info("Expanding the matched selectors");
    1.27 +  propertyView.matchedExpanded = true;
    1.28 +  yield propertyView.refreshMatchedSelectors();
    1.29 +
    1.30 +  let span = propertyView.matchedSelectorsContainer.querySelector("span.rule-text");
    1.31 +  ok(span, "Found the first table row");
    1.32 +
    1.33 +  let selector = propertyView.matchedSelectorViews[0];
    1.34 +  ok(selector, "Found the first matched selector view");
    1.35 +});
    1.36 +
    1.37 +function getPropertyView(computedView, name) {
    1.38 +  let propertyView = null;
    1.39 +  computedView.propertyViews.some(function(view) {
    1.40 +    if (view.name == name) {
    1.41 +      propertyView = view;
    1.42 +      return true;
    1.43 +    }
    1.44 +    return false;
    1.45 +  });
    1.46 +  return propertyView;
    1.47 +}

mercurial