Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test for @-moz-document rules</title> |
michael@0 | 5 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 7 | <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> |
michael@0 | 8 | </head> |
michael@0 | 9 | <body onload="run()"> |
michael@0 | 10 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=398962">Mozilla Bug 398962</a> |
michael@0 | 11 | <iframe id="iframe" src="http://mochi.test:8888/tests/layout/style/test/chrome/moz_document_helper.html"></iframe> |
michael@0 | 12 | <pre id="test"> |
michael@0 | 13 | <script type="application/javascript; version=1.8"> |
michael@0 | 14 | |
michael@0 | 15 | var [gStyleSheetService, gIOService] = (function() { |
michael@0 | 16 | return [ |
michael@0 | 17 | Components.classes["@mozilla.org/content/style-sheet-service;1"] |
michael@0 | 18 | .getService(Components.interfaces.nsIStyleSheetService), |
michael@0 | 19 | Components.classes["@mozilla.org/network/io-service;1"] |
michael@0 | 20 | .getService(Components.interfaces.nsIIOService) |
michael@0 | 21 | ]; |
michael@0 | 22 | })(); |
michael@0 | 23 | function set_user_sheet(sheeturi) |
michael@0 | 24 | { |
michael@0 | 25 | var uri = gIOService.newURI(sheeturi, null, null); |
michael@0 | 26 | gStyleSheetService.loadAndRegisterSheet(uri, gStyleSheetService.USER_SHEET); |
michael@0 | 27 | } |
michael@0 | 28 | function remove_user_sheet(sheeturi) |
michael@0 | 29 | { |
michael@0 | 30 | var uri = gIOService.newURI(sheeturi, null, null); |
michael@0 | 31 | gStyleSheetService.unregisterSheet(uri, gStyleSheetService.USER_SHEET); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | function run() |
michael@0 | 35 | { |
michael@0 | 36 | var iframe = document.getElementById("iframe"); |
michael@0 | 37 | var subdoc = iframe.contentDocument; |
michael@0 | 38 | var subwin = iframe.contentWindow; |
michael@0 | 39 | var cs = subwin.getComputedStyle(subdoc.getElementById("display"), ""); |
michael@0 | 40 | var zIndexCounter = 0; |
michael@0 | 41 | |
michael@0 | 42 | function test_document_rule(urltests, shouldapply) |
michael@0 | 43 | { |
michael@0 | 44 | var zIndex = ++zIndexCounter; |
michael@0 | 45 | var encodedRule = encodeURI("@-moz-document " + urltests + " { ") + |
michael@0 | 46 | "%23" + // encoded hash character for "#display" |
michael@0 | 47 | encodeURI("display { z-index: " + zIndex + " } }"); |
michael@0 | 48 | var sheeturi = "data:text/css," + encodedRule; |
michael@0 | 49 | set_user_sheet(sheeturi); |
michael@0 | 50 | if (shouldapply) { |
michael@0 | 51 | is(cs.zIndex, zIndex, |
michael@0 | 52 | "@-moz-document " + urltests + |
michael@0 | 53 | " should apply to this document"); |
michael@0 | 54 | } else { |
michael@0 | 55 | is(cs.zIndex, "auto", |
michael@0 | 56 | "@-moz-document " + urltests + |
michael@0 | 57 | " should NOT apply to this document"); |
michael@0 | 58 | } |
michael@0 | 59 | remove_user_sheet(sheeturi); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | test_document_rule("domain(mochi.test)", true); |
michael@0 | 63 | test_document_rule("domain(\"mochi.test\")", true); |
michael@0 | 64 | test_document_rule("domain('mochi.test')", true); |
michael@0 | 65 | test_document_rule("domain('test')", true); |
michael@0 | 66 | test_document_rule("domain(.test)", false); |
michael@0 | 67 | test_document_rule("domain('.test')", false); |
michael@0 | 68 | test_document_rule("domain('ochi.test')", false); |
michael@0 | 69 | test_document_rule("domain(ochi.test)", false); |
michael@0 | 70 | test_document_rule("url-prefix(http://moch)", true); |
michael@0 | 71 | test_document_rule("url-prefix(http://och)", false); |
michael@0 | 72 | test_document_rule("url-prefix(http://mochi.test)", true); |
michael@0 | 73 | test_document_rule("url-prefix(http://mochi.test:88)", true); |
michael@0 | 74 | test_document_rule("url-prefix(http://mochi.test:8888)", true); |
michael@0 | 75 | test_document_rule("url-prefix(http://mochi.test:8888/)", true); |
michael@0 | 76 | test_document_rule("url-prefix('http://mochi.test:8888/tests/layout/style/test/chrome/moz_document_helper.html')", true); |
michael@0 | 77 | test_document_rule("url-prefix('http://mochi.test:8888/tests/layout/style/test/chrome/moz_document_helper.htmlx')", false); |
michael@0 | 78 | test_document_rule("url(http://mochi.test:8888/)", false); |
michael@0 | 79 | test_document_rule("url('http://mochi.test:8888/tests/layout/style/test/chrome/moz_document_helper.html')", true); |
michael@0 | 80 | test_document_rule("url('http://mochi.test:8888/tests/layout/style/test/chrome/moz_document_helper.htmlx')", false); |
michael@0 | 81 | test_document_rule("regexp(.*ochi.*)", false); // syntax error |
michael@0 | 82 | test_document_rule("regexp('.*ochi.*')", true); |
michael@0 | 83 | test_document_rule("regexp('ochi.*')", false); |
michael@0 | 84 | test_document_rule("regexp('.*ochi')", false); |
michael@0 | 85 | test_document_rule("regexp('http:.*ochi.*')", true); |
michael@0 | 86 | test_document_rule("regexp('http:.*ochi')", false); |
michael@0 | 87 | test_document_rule("regexp('http:.*oCHi.*')", false); // case sensitive |
michael@0 | 88 | |
michael@0 | 89 | SimpleTest.finish(); |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 93 | |
michael@0 | 94 | </script> |
michael@0 | 95 | </pre> |
michael@0 | 96 | </body> |
michael@0 | 97 | </html> |