summaryrefslogtreecommitdiff
path: root/browser/devtools/styleinspector/test/browser_bug_692400_element_style.js
blob: 484ea28afdbeb77e623c629e8bdb883e82d3d375 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* 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/ */

// Tests for selector text errors.

let doc;
let computedView;

function createDocument()
{
  doc.body.innerHTML = "<div style='color:blue;'></div>";

  doc.title = "Style Inspector Selector Text Test";

  openInspector(openComputedView);
}


function openComputedView(aInspector)
{
  let div = doc.querySelector("div");
  ok(div, "captain, we have the test div");

  aInspector.selection.setNode(div);

  aInspector.sidebar.once("computedview-ready", function() {
    aInspector.sidebar.select("computedview");
    computedView = getComputedView(aInspector);

    Services.obs.addObserver(SI_checkText, "StyleInspector-populated", false);
  });
}

function SI_checkText()
{
  Services.obs.removeObserver(SI_checkText, "StyleInspector-populated");

  let propertyView = null;
  computedView.propertyViews.some(function(aView) {
    if (aView.name == "color") {
      propertyView = aView;
      return true;
    }
    return false;
  });

  ok(propertyView, "found PropertyView for color");

  is(propertyView.hasMatchedSelectors, true, "hasMatchedSelectors is true");

  propertyView.matchedExpanded = true;
  propertyView.refreshMatchedSelectors();

  let span = propertyView.matchedSelectorsContainer.querySelector("span.rule-text");
  ok(span, "found the first table row");

  let selector = propertyView.matchedSelectorViews[0];
  ok(selector, "found the first matched selector view");

  finishUp();
}

function finishUp()
{
  doc = computedView = null;
  gBrowser.removeCurrentTab();
  finish();
}

function test()
{
  waitForExplicitFinish();
  gBrowser.selectedTab = gBrowser.addTab();
  gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) {
    gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true);
    doc = content.document;
    waitForFocus(createDocument, content);
  }, true);

  content.location = "data:text/html,selector text test, bug 692400";
}