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