Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <!-- |
michael@0 | 3 | vim: set ts=2 et sw=2 tw=80: |
michael@0 | 4 | Any copyright is dedicated to the Public Domain. |
michael@0 | 5 | http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 6 | --> |
michael@0 | 7 | <?xml-stylesheet type="text/css" href="chrome://global/skin"?> |
michael@0 | 8 | <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> |
michael@0 | 9 | <?xml-stylesheet type="text/css" href="test_bug727834.css"?> |
michael@0 | 10 | <window title="Mozilla Bug 727834" |
michael@0 | 11 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 12 | onload="RunTests();"> |
michael@0 | 13 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
michael@0 | 14 | <script type="application/javascript"><![CDATA[ |
michael@0 | 15 | /** Test for Bug 727834 - Add an API to (re)parse a style sheet in place **/ |
michael@0 | 16 | |
michael@0 | 17 | function RunTests() { |
michael@0 | 18 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 19 | |
michael@0 | 20 | let DOMUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"] |
michael@0 | 21 | .getService(Components.interfaces.inIDOMUtils); |
michael@0 | 22 | let body = document.querySelector("body"); |
michael@0 | 23 | let testSheet = document.styleSheets[2]; |
michael@0 | 24 | let rule = document.styleSheets[2].cssRules[0]; |
michael@0 | 25 | |
michael@0 | 26 | is(testSheet.cssRules.length, 1, |
michael@0 | 27 | "style sheet has 1 rule"); |
michael@0 | 28 | is(rule.style.paddingTop, "100px", |
michael@0 | 29 | "original first rule has padding-top 100px"); |
michael@0 | 30 | is(window.getComputedStyle(body).paddingTop, "100px", |
michael@0 | 31 | "original first rule applies"); |
michael@0 | 32 | |
michael@0 | 33 | DOMUtils.parseStyleSheet(testSheet, |
michael@0 | 34 | "@import url(test_bug727834.css); body{background: red;}"); |
michael@0 | 35 | |
michael@0 | 36 | is(testSheet.cssRules.length, 2, |
michael@0 | 37 | "style sheet now has 2 rules"); |
michael@0 | 38 | is(window.getComputedStyle(body).backgroundColor, "rgb(255, 0, 0)", |
michael@0 | 39 | "background is now red"); |
michael@0 | 40 | |
michael@0 | 41 | let exceptionName; |
michael@0 | 42 | try { |
michael@0 | 43 | rule.style.paddingLeft = "100px"; |
michael@0 | 44 | } catch (ex) { |
michael@0 | 45 | exceptionName = ex.name; |
michael@0 | 46 | } finally { |
michael@0 | 47 | is(exceptionName, "NS_ERROR_NOT_AVAILABLE", |
michael@0 | 48 | "original rule is not available for modification anymore"); |
michael@0 | 49 | } |
michael@0 | 50 | is(window.getComputedStyle(body).paddingLeft, "0px", |
michael@0 | 51 | "original rule does not apply to document"); |
michael@0 | 52 | |
michael@0 | 53 | rule = testSheet.cssRules[0]; |
michael@0 | 54 | |
michael@0 | 55 | is(rule.parentStyleSheet, testSheet, |
michael@0 | 56 | "rule's parent style sheet is not null"); |
michael@0 | 57 | |
michael@0 | 58 | DOMUtils.parseStyleSheet(testSheet, |
michael@0 | 59 | "body{background: lime;}"); |
michael@0 | 60 | |
michael@0 | 61 | is(testSheet.cssRules.length, 1, |
michael@0 | 62 | "style sheet now has 1 rule"); |
michael@0 | 63 | is(window.getComputedStyle(body).backgroundColor, "rgb(0, 255, 0)", |
michael@0 | 64 | "background is now lime"); |
michael@0 | 65 | is(rule.parentStyleSheet, null, |
michael@0 | 66 | "detached rule's parent style sheet is null"); |
michael@0 | 67 | |
michael@0 | 68 | SimpleTest.executeSoon(function () { |
michael@0 | 69 | DOMUtils.parseStyleSheet(testSheet, |
michael@0 | 70 | "@import url(test_bug727834.css); body{background: blue;}"); |
michael@0 | 71 | |
michael@0 | 72 | is(testSheet.cssRules.length, 2, |
michael@0 | 73 | "style sheet now has 2 rules"); |
michael@0 | 74 | is(window.getComputedStyle(body).backgroundColor, "rgb(0, 0, 255)", |
michael@0 | 75 | "background is now blue"); |
michael@0 | 76 | is(testSheet.cssRules[0].parentStyleSheet, testSheet, |
michael@0 | 77 | "parent style sheet is the test sheet"); |
michael@0 | 78 | |
michael@0 | 79 | SimpleTest.finish(); |
michael@0 | 80 | }); |
michael@0 | 81 | } |
michael@0 | 82 | ]]></script> |
michael@0 | 83 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 84 | <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=727834"> |
michael@0 | 85 | Mozilla Bug 727834 - Add an API to (re)parse a style sheet in place |
michael@0 | 86 | </a> |
michael@0 | 87 | </body> |
michael@0 | 88 | </window> |