|
1 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ |
|
2 /* Any copyright is dedicated to the Public Domain. |
|
3 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
7 // Tests that the checkbox to include browser styles works properly. |
|
8 |
|
9 let test = asyncTest(function*() { |
|
10 yield addTab("data:text/html,default styles test"); |
|
11 |
|
12 info("Creating the test document"); |
|
13 content.document.body.innerHTML = '<style type="text/css"> ' + |
|
14 '.matches {color: #F00;}</style>' + |
|
15 '<span id="matches" class="matches">Some styled text</span>' + |
|
16 '</div>'; |
|
17 content.document.title = "Style Inspector Default Styles Test"; |
|
18 |
|
19 info("Opening the computed view"); |
|
20 let {toolbox, inspector, view} = yield openComputedView(); |
|
21 |
|
22 info("Selecting the test node"); |
|
23 yield selectNode("#matches", inspector); |
|
24 |
|
25 info("Checking the default styles"); |
|
26 is(isPropertyVisible("color", view), true, |
|
27 "span #matches color property is visible"); |
|
28 is(isPropertyVisible("background-color", view), false, |
|
29 "span #matches background-color property is hidden"); |
|
30 |
|
31 info("Toggling the browser styles"); |
|
32 let doc = view.styleDocument; |
|
33 let checkbox = doc.querySelector(".includebrowserstyles"); |
|
34 let onRefreshed = inspector.once("computed-view-refreshed"); |
|
35 checkbox.click(); |
|
36 yield onRefreshed; |
|
37 |
|
38 info("Checking the browser styles"); |
|
39 is(isPropertyVisible("color", view), true, |
|
40 "span color property is visible"); |
|
41 is(isPropertyVisible("background-color", view), true, |
|
42 "span background-color property is visible"); |
|
43 }); |
|
44 |
|
45 function isPropertyVisible(name, view) { |
|
46 info("Checking property visibility for " + name); |
|
47 let propertyViews = view.propertyViews; |
|
48 for each (let propView in propertyViews) { |
|
49 if (propView.name == name) { |
|
50 return propView.visible; |
|
51 } |
|
52 } |
|
53 return false; |
|
54 } |