|
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 // Test that the rule view refreshes when the current node has its style |
|
8 // changed |
|
9 |
|
10 const TESTCASE_URI = 'data:text/html;charset=utf-8,' + |
|
11 '<div id="testdiv" style="font-size:10px;">Test div!</div>'; |
|
12 |
|
13 let test = asyncTest(function*() { |
|
14 yield addTab(TESTCASE_URI); |
|
15 |
|
16 Services.prefs.setCharPref("devtools.defaultColorUnit", "name"); |
|
17 |
|
18 info("Getting the test node"); |
|
19 let div = getNode("#testdiv"); |
|
20 |
|
21 info("Opening the rule view and selecting the test node"); |
|
22 let {toolbox, inspector, view} = yield openRuleView(); |
|
23 yield selectNode(div, inspector); |
|
24 |
|
25 let fontSize = getRuleViewPropertyValue(view, "element", "font-size"); |
|
26 is(fontSize, "10px", "The rule view shows the right font-size"); |
|
27 |
|
28 info("Changing the node's style and waiting for the update"); |
|
29 let onUpdated = inspector.once("rule-view-refreshed"); |
|
30 div.style.cssText = "font-size: 3em; color: lightgoldenrodyellow; text-align: right; text-transform: uppercase"; |
|
31 yield onUpdated; |
|
32 |
|
33 let textAlign = getRuleViewPropertyValue(view, "element", "text-align"); |
|
34 is(textAlign, "right", "The rule view shows the new text align."); |
|
35 let color = getRuleViewPropertyValue(view, "element", "color"); |
|
36 is(color, "lightgoldenrodyellow", "The rule view shows the new color.") |
|
37 let fontSize = getRuleViewPropertyValue(view, "element", "font-size"); |
|
38 is(fontSize, "3em", "The rule view shows the new font size."); |
|
39 let textTransform = getRuleViewPropertyValue(view, "element", "text-transform"); |
|
40 is(textTransform, "uppercase", "The rule view shows the new text transform."); |
|
41 }); |