|
1 <!DOCTYPE html> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=682592 |
|
5 --> |
|
6 <head> |
|
7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" > |
|
8 <title>Test for bug 682592</title> |
|
9 <script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script> |
|
10 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
12 </head> |
|
13 <body> |
|
14 <p id="display"></p> |
|
15 <div id="content"> |
|
16 <iframe id="iframe-ref" src="bug682592-subframe-ref.html"></iframe> |
|
17 <iframe id="iframe-test"></iframe> |
|
18 </div> |
|
19 <pre id="test"> |
|
20 <script class="testbody" type="text/javascript;version=1.7"> |
|
21 /** Test for Bug 682592 **/ |
|
22 |
|
23 /* |
|
24 We want to check that bidi is detected correctly. So, we have a reference |
|
25 document where ltr is set explicitely with <bdo> element. Then, we compare |
|
26 it with test document. |
|
27 |
|
28 In mozilla, once bidi has been detected in a document, document always |
|
29 consider it's in bidi mode. So, if one fragment enables bidi correctly, and |
|
30 we create or update a fragment in the same document, that operation may not |
|
31 enable bidi by itself, but it will not be detected. So, we need to have new |
|
32 document for each test. |
|
33 |
|
34 So, instead of many diferent reftests, this mochitest implements a |
|
35 reftest-like. It creates reference text fragments in reference iframe, test |
|
36 text fragments in test iframe, and compare the documents. Then, it reloads |
|
37 test iframe. Reference iframe does not need to be reloaded between tests. |
|
38 It's ok (and maybe, desired) to keep bidi always enabled in that document. |
|
39 */ |
|
40 |
|
41 SimpleTest.waitForExplicitFinish(); |
|
42 if (navigator.platform.startsWith("Linux arm")) { /* bugs 982875, 999429 */ |
|
43 SimpleTest.expectAssertions(0, 4); |
|
44 } |
|
45 |
|
46 var refFrame = document.getElementById("iframe-ref") |
|
47 var testFrame = document.getElementById("iframe-test"); |
|
48 |
|
49 refFrame.addEventListener("load", function() { |
|
50 testFrame.addEventListener("load", function() { |
|
51 try { |
|
52 tests.next(); |
|
53 ok(compareSnapshots(snapshotWindow(testFrame.contentWindow), |
|
54 snapshotWindow(refFrame.contentWindow), true)[0], |
|
55 "bidi is not detected correctly"); |
|
56 |
|
57 testFrame.contentWindow.location.reload(); |
|
58 } catch (err if err instanceof StopIteration) { |
|
59 SimpleTest.finish(); |
|
60 } |
|
61 }, false); |
|
62 testFrame.src = "bug682592-subframe.html" |
|
63 }, false); |
|
64 |
|
65 var rtl = "עִבְרִית"; |
|
66 var non8bit = "ʃ"; |
|
67 var is8bit = "a"; |
|
68 |
|
69 // concats aStr aNumber of times |
|
70 function strMult(aStr, aNumber) { |
|
71 if (aNumber === 0) { |
|
72 return ""; |
|
73 } |
|
74 return strMult(aStr, aNumber - 1) + aStr; |
|
75 } |
|
76 |
|
77 function runTests () { |
|
78 var ltr = "", prefix = null; |
|
79 var refContainer = refFrame.contentDocument.getElementById('content'); |
|
80 var testContainer, textNode; |
|
81 var i = 0; |
|
82 |
|
83 // 8bit chars + bidi |
|
84 for (i = 0; i <= 16; i++) { |
|
85 ltr = strMult(is8bit, i); |
|
86 refContainer.innerHTML = ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; |
|
87 testContainer = testFrame.contentDocument.getElementById('content'); |
|
88 testContainer.innerHTML = ltr + rtl; |
|
89 yield undefined; |
|
90 } |
|
91 |
|
92 // non-8bit char + 8bit chars + bidi |
|
93 for (i = 0; i <= 16; i++) { |
|
94 ltr = non8bit + strMult(is8bit, i); |
|
95 refContainer.innerHTML = ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; |
|
96 testContainer = testFrame.contentDocument.getElementById('content'); |
|
97 testContainer.innerHTML = ltr + rtl; |
|
98 yield undefined; |
|
99 } |
|
100 |
|
101 // appendData |
|
102 for (i = 0; i <= 16; i++) { |
|
103 ltr = strMult(is8bit, i); |
|
104 refContainer.innerHTML = ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; |
|
105 testContainer = testFrame.contentDocument.getElementById('content'); |
|
106 textNode = document.createTextNode(""); |
|
107 testContainer.appendChild(textNode); |
|
108 textNode.appendData(ltr + rtl); |
|
109 yield undefined; |
|
110 } |
|
111 |
|
112 for (i = 0; i <= 16; i++) { |
|
113 ltr = non8bit + strMult(is8bit, i); |
|
114 refContainer.innerHTML = ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; |
|
115 testContainer = testFrame.contentDocument.getElementById('content'); |
|
116 textNode = document.createTextNode(""); |
|
117 testContainer.appendChild(textNode); |
|
118 textNode.appendData(ltr + rtl); |
|
119 yield undefined; |
|
120 } |
|
121 |
|
122 // appendData with 8bit prefix |
|
123 for (i = 0; i <= 16; i++) { |
|
124 prefix = is8bit; |
|
125 ltr = strMult(is8bit, i); |
|
126 refContainer.innerHTML = prefix + ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; |
|
127 testContainer = testFrame.contentDocument.getElementById('content'); |
|
128 textNode = document.createTextNode(prefix); |
|
129 testContainer.appendChild(textNode); |
|
130 textNode.appendData(ltr + rtl); |
|
131 yield undefined; |
|
132 } |
|
133 |
|
134 for (i = 0; i <= 16; i++) { |
|
135 prefix = is8bit; |
|
136 ltr = non8bit + strMult(is8bit, i); |
|
137 refContainer.innerHTML = prefix + ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; |
|
138 testContainer = testFrame.contentDocument.getElementById('content'); |
|
139 textNode = document.createTextNode(prefix); |
|
140 testContainer.appendChild(textNode); |
|
141 textNode.appendData(ltr + rtl); |
|
142 yield undefined; |
|
143 } |
|
144 |
|
145 // appendData with non-8bit prefix |
|
146 for (i = 0; i <= 16; i++) { |
|
147 prefix = non8bit; |
|
148 ltr = strMult(is8bit, i); |
|
149 refContainer.innerHTML = prefix + ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; |
|
150 testContainer = testFrame.contentDocument.getElementById('content'); |
|
151 textNode = document.createTextNode(prefix); |
|
152 testContainer.appendChild(textNode); |
|
153 textNode.appendData(ltr + rtl); |
|
154 yield undefined; |
|
155 } |
|
156 |
|
157 for (i = 0; i <= 16; i++) { |
|
158 prefix = non8bit; |
|
159 ltr = non8bit + strMult(is8bit, i); |
|
160 refContainer.innerHTML = prefix + ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; |
|
161 testContainer = testFrame.contentDocument.getElementById('content'); |
|
162 textNode = document.createTextNode(prefix); |
|
163 testContainer.appendChild(textNode); |
|
164 textNode.appendData(ltr + rtl); |
|
165 yield undefined; |
|
166 } |
|
167 }; |
|
168 |
|
169 var tests = runTests(); |
|
170 |
|
171 </script> |
|
172 </pre> |
|
173 </body> |
|
174 </html> |