summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/computed/test/browser_computed_matched-selectors_01.js
blob: 66cabe7a9a0f0372b6c4b2b5adc69fed1a72e0d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Checking selector counts, matched rules and titles in the computed-view.

const {PropertyView} =
      require("devtools/client/inspector/computed/computed");
const TEST_URI = URL_ROOT + "doc_matched_selectors.html";

add_task(function* () {
  yield addTab(TEST_URI);
  let {inspector, view} = yield openComputedView();

  yield selectNode("#test", inspector);
  yield testMatchedSelectors(view, inspector);
});

function* testMatchedSelectors(view, inspector) {
  info("checking selector counts, matched rules and titles");

  let nodeFront = yield getNodeFront("#test", inspector);
  is(nodeFront, view._viewedElement,
    "style inspector node matches the selected node");

  let propertyView = new PropertyView(view, "color");
  propertyView.buildMain();
  propertyView.buildSelectorContainer();
  propertyView.matchedExpanded = true;

  yield propertyView.refreshMatchedSelectors();

  let numMatchedSelectors = propertyView.matchedSelectors.length;
  is(numMatchedSelectors, 6,
    "CssLogic returns the correct number of matched selectors for div");
  is(propertyView.hasMatchedSelectors, true,
    "hasMatchedSelectors returns true");
}