Wed, 31 Dec 2014 07:16:47 +0100
Revert simplistic fix pending revisit of Mozilla integration attempt.
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Test that preffed off properties do not appear in computed style</title>
5 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
7 </head>
8 <body>
9 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=919594">Mozilla Bug 919594</a>
10 <p id="display"></p>
11 <div id="content" style="display: none">
13 </div>
14 <pre id="test">
15 <script type="application/javascript; version=1.7">
17 /** Test that preffed off properties do not appear in computed style **/
19 function testWithAllPrefsDisabled() {
20 let exposedProperties = Object.keys(gCS).map(i => gCS[i]);
22 // Store the number of properties for later tests to use.
23 gLengthWithAllPrefsDisabled = gCS.length;
25 // Check that all of the properties behind the prefs are not exposed.
26 for (let pref in gProps) {
27 for (let prop of gProps[pref]) {
28 ok(exposedProperties.indexOf(prop) == -1, prop + " not exposed when prefs are false");
29 }
30 }
31 }
33 function testWithOnePrefEnabled(aPref) {
34 let exposedProperties = Object.keys(gCS).map(i => gCS[i]);
36 // Check that the number of properties on the object is as expected.
37 is(gCS.length, gLengthWithAllPrefsDisabled + gProps[aPref].length, "length when " + aPref + " is true");
39 // Check that the properties corresponding to aPref are exposed.
40 for (let prop of gProps[aPref]) {
41 ok(exposedProperties.indexOf(prop) != -1, prop + " exposed when " + aPref + " is true");
42 }
43 }
45 function step() {
46 if (gTestIndex == gTests.length) {
47 // Reached the end of the tests.
48 SimpleTest.finish();
49 return;
50 }
52 if (gPrefsPushed) {
53 // We've just finished running one tests. Pop the prefs and go on to
54 // the next test.
55 gTestIndex++;
56 gPrefsPushed = false;
57 SpecialPowers.popPrefEnv(step);
58 return;
59 }
61 // About to run one test. Push the prefs and run it.
62 let fn = gTests[gTestIndex].fn;
63 gPrefsPushed = true;
64 SpecialPowers.pushPrefEnv(gTests[gTestIndex].settings,
65 function() { fn(); SimpleTest.executeSoon(step); });
66 }
68 // ----
70 var gProps = {
71 "layout.css.vertical-text.enabled": ["text-combine-upright", "text-orientation", "writing-mode"],
72 "layout.css.font-features.enabled": ["font-kerning", "font-synthesis", "font-variant-alternates", "font-variant-caps", "font-variant-east-asian", "font-variant-ligatures", "font-variant-numeric", "font-variant-position"],
73 "layout.css.image-orientation.enabled": ["image-orientation"],
74 "layout.css.mix-blend-mode.enabled": ["mix-blend-mode"],
75 "layout.css.masking.enabled": ["mask-type"],
76 "layout.css.touch_action.enabled": ["touch-action"]
77 };
79 var gCS = getComputedStyle(document.body, "");
80 var gLengthWithAllPrefsDisabled;
82 var gTestIndex = 0;
83 var gPrefsPushed = false;
84 var gTests = [
85 // First, test when all of the prefs are disabled.
86 { settings: { set: Object.keys(gProps).map(x => [x, false]) },
87 fn: testWithAllPrefsDisabled },
88 // Then, test each pref enabled individually.
89 ...Object.keys(gProps).map(p =>
90 ({ settings: { set: Object.keys(gProps).map(x => [x, x == p]) },
91 fn: testWithOnePrefEnabled.bind(null, p) }))
92 ];
94 SimpleTest.waitForExplicitFinish();
95 step();
96 </script>
97 </pre>
98 </body>
99 </html>