Bug 458861. Validate TrueType headers before activating downloaded font. r=roc, sr...
[wine-gecko.git] / layout / style / test / test_cascade.html
blob25ab02e0b07caec7b1bd471567f328898d90e144
1 <!DOCTYPE HTML>
2 <!-- vim: set shiftwidth=4 tabstop=8 autoindent expandtab: -->
3 <!-- ***** BEGIN LICENSE BLOCK *****
4 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 - The contents of this file are subject to the Mozilla Public License Version
7 - 1.1 (the "License"); you may not use this file except in compliance with
8 - the License. You may obtain a copy of the License at
9 - http://www.mozilla.org/MPL/
11 - Software distributed under the License is distributed on an "AS IS" basis,
12 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 - for the specific language governing rights and limitations under the
14 - License.
16 - The Original Code is test_cascade.html
18 - The Initial Developer of the Original Code is the Mozilla Foundation.
19 - Portions created by the Initial Developer are Copyright (C) 2008
20 - the Initial Developer. All Rights Reserved.
22 - Contributor(s):
23 - L. David Baron <dbaron@dbaron.org>, Mozilla Corporation (original author)
25 - Alternatively, the contents of this file may be used under the terms of
26 - either the GNU General Public License Version 2 or later (the "GPL"), or
27 - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 - in which case the provisions of the GPL or the LGPL are applicable instead
29 - of those above. If you wish to allow use of your version of this file only
30 - under the terms of either the GPL or the LGPL, and not to allow others to
31 - use your version of this file under the terms of the MPL, indicate your
32 - decision by deleting the provisions above and replace them with the notice
33 - and other provisions required by the LGPL or the GPL. If you do not delete
34 - the provisions above, a recipient may use your version of this file under
35 - the terms of any one of the MPL, the GPL or the LGPL.
37 - ***** END LICENSE BLOCK ***** -->
38 <html>
39 <head>
40 <title>Test for Author style sheet aspects of CSS cascading</title>
41 <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
42 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
43 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
44 <style type="text/css">
46 </style>
47 </head>
48 <body id="thebody">
49 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
50 <div class="content_class" id="content" style="position:relative"></div>
51 <pre id="test">
52 <script class="testbody" type="text/javascript">
54 /** Test for Author style sheet aspects of CSS cascading **/
56 var style_element = document.createElement("style");
57 var style_contents = document.createTextNode("");
58 style_element.appendChild(style_contents);
59 document.getElementsByTagName("head")[0].appendChild(style_element);
61 var div = document.getElementById("content");
62 var cs = window.getComputedStyle(div, "");
63 var zindex = 0;
65 /**
66 * Given the selectors |sel1| and |sel2|, in that order (the "order"
67 * aspect of the cascade), with declarations that are !important if
68 * |imp1|/|imp2| are true, assert that the one that wins in the
69 * cascading order is given by |winning| (which must be either 1 or 2).
71 function do_test(sel1, imp1, sel2, imp2, winning) {
72 var ind1 = ++zindex;
73 var ind2 = ++zindex;
74 style_contents.data =
75 sel1 + " { z-index: " + ind1 + (imp1 ? "!important" :"") + " } " +
76 sel2 + " { z-index: " + ind2 + (imp2 ? "!important" :"") + " } ";
77 var result = cs.zIndex;
78 is(result, (winning == 1) ? ind1 : ind2,
79 "cascading of " + style_element.data);
82 // Test order, and order combined with !important
83 do_test("div", false, "div", false, 2);
84 do_test("div", false, "div", true, 2);
85 do_test("div", true, "div", false, 1);
86 do_test("div", true, "div", true, 2);
88 // Test specificity on a single element
89 do_test("div", false, "div.content_class", false, 2);
90 do_test("div.content_class", false, "div", false, 1);
92 // Test specificity across elements
93 do_test("body#thebody div", false, "body div.content_class", false, 1);
94 do_test("body div.content_class", false, "body#thebody div", false, 2);
96 // Test specificity combined with !important
97 do_test("div.content_class", false, "div", false, 1);
98 do_test("div.content_class", true, "div", false, 1);
99 do_test("div.content_class", false, "div", true, 2);
100 do_test("div.content_class", true, "div", true, 1);
102 </script>
103 </pre>
104 </body>
105 </html>