1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_bug682592.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,174 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=682592 1.8 +--> 1.9 +<head> 1.10 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" > 1.11 + <title>Test for bug 682592</title> 1.12 + <script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script> 1.13 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.14 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.15 +</head> 1.16 +<body> 1.17 +<p id="display"></p> 1.18 +<div id="content"> 1.19 +<iframe id="iframe-ref" src="bug682592-subframe-ref.html"></iframe> 1.20 +<iframe id="iframe-test"></iframe> 1.21 +</div> 1.22 +<pre id="test"> 1.23 +<script class="testbody" type="text/javascript;version=1.7"> 1.24 +/** Test for Bug 682592 **/ 1.25 + 1.26 +/* 1.27 + We want to check that bidi is detected correctly. So, we have a reference 1.28 + document where ltr is set explicitely with <bdo> element. Then, we compare 1.29 + it with test document. 1.30 + 1.31 + In mozilla, once bidi has been detected in a document, document always 1.32 + consider it's in bidi mode. So, if one fragment enables bidi correctly, and 1.33 + we create or update a fragment in the same document, that operation may not 1.34 + enable bidi by itself, but it will not be detected. So, we need to have new 1.35 + document for each test. 1.36 + 1.37 + So, instead of many diferent reftests, this mochitest implements a 1.38 + reftest-like. It creates reference text fragments in reference iframe, test 1.39 + text fragments in test iframe, and compare the documents. Then, it reloads 1.40 + test iframe. Reference iframe does not need to be reloaded between tests. 1.41 + It's ok (and maybe, desired) to keep bidi always enabled in that document. 1.42 +*/ 1.43 + 1.44 +SimpleTest.waitForExplicitFinish(); 1.45 +if (navigator.platform.startsWith("Linux arm")) { /* bugs 982875, 999429 */ 1.46 + SimpleTest.expectAssertions(0, 4); 1.47 +} 1.48 + 1.49 +var refFrame = document.getElementById("iframe-ref") 1.50 +var testFrame = document.getElementById("iframe-test"); 1.51 + 1.52 +refFrame.addEventListener("load", function() { 1.53 + testFrame.addEventListener("load", function() { 1.54 + try { 1.55 + tests.next(); 1.56 + ok(compareSnapshots(snapshotWindow(testFrame.contentWindow), 1.57 + snapshotWindow(refFrame.contentWindow), true)[0], 1.58 + "bidi is not detected correctly"); 1.59 + 1.60 + testFrame.contentWindow.location.reload(); 1.61 + } catch (err if err instanceof StopIteration) { 1.62 + SimpleTest.finish(); 1.63 + } 1.64 + }, false); 1.65 + testFrame.src = "bug682592-subframe.html" 1.66 +}, false); 1.67 + 1.68 +var rtl = "עִבְרִית"; 1.69 +var non8bit = "ʃ"; 1.70 +var is8bit = "a"; 1.71 + 1.72 +// concats aStr aNumber of times 1.73 +function strMult(aStr, aNumber) { 1.74 + if (aNumber === 0) { 1.75 + return ""; 1.76 + } 1.77 + return strMult(aStr, aNumber - 1) + aStr; 1.78 +} 1.79 + 1.80 +function runTests () { 1.81 + var ltr = "", prefix = null; 1.82 + var refContainer = refFrame.contentDocument.getElementById('content'); 1.83 + var testContainer, textNode; 1.84 + var i = 0; 1.85 + 1.86 + // 8bit chars + bidi 1.87 + for (i = 0; i <= 16; i++) { 1.88 + ltr = strMult(is8bit, i); 1.89 + refContainer.innerHTML = ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; 1.90 + testContainer = testFrame.contentDocument.getElementById('content'); 1.91 + testContainer.innerHTML = ltr + rtl; 1.92 + yield undefined; 1.93 + } 1.94 + 1.95 + // non-8bit char + 8bit chars + bidi 1.96 + for (i = 0; i <= 16; i++) { 1.97 + ltr = non8bit + strMult(is8bit, i); 1.98 + refContainer.innerHTML = ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; 1.99 + testContainer = testFrame.contentDocument.getElementById('content'); 1.100 + testContainer.innerHTML = ltr + rtl; 1.101 + yield undefined; 1.102 + } 1.103 + 1.104 + // appendData 1.105 + for (i = 0; i <= 16; i++) { 1.106 + ltr = strMult(is8bit, i); 1.107 + refContainer.innerHTML = ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; 1.108 + testContainer = testFrame.contentDocument.getElementById('content'); 1.109 + textNode = document.createTextNode(""); 1.110 + testContainer.appendChild(textNode); 1.111 + textNode.appendData(ltr + rtl); 1.112 + yield undefined; 1.113 + } 1.114 + 1.115 + for (i = 0; i <= 16; i++) { 1.116 + ltr = non8bit + strMult(is8bit, i); 1.117 + refContainer.innerHTML = ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; 1.118 + testContainer = testFrame.contentDocument.getElementById('content'); 1.119 + textNode = document.createTextNode(""); 1.120 + testContainer.appendChild(textNode); 1.121 + textNode.appendData(ltr + rtl); 1.122 + yield undefined; 1.123 + } 1.124 + 1.125 + // appendData with 8bit prefix 1.126 + for (i = 0; i <= 16; i++) { 1.127 + prefix = is8bit; 1.128 + ltr = strMult(is8bit, i); 1.129 + refContainer.innerHTML = prefix + ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; 1.130 + testContainer = testFrame.contentDocument.getElementById('content'); 1.131 + textNode = document.createTextNode(prefix); 1.132 + testContainer.appendChild(textNode); 1.133 + textNode.appendData(ltr + rtl); 1.134 + yield undefined; 1.135 + } 1.136 + 1.137 + for (i = 0; i <= 16; i++) { 1.138 + prefix = is8bit; 1.139 + ltr = non8bit + strMult(is8bit, i); 1.140 + refContainer.innerHTML = prefix + ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; 1.141 + testContainer = testFrame.contentDocument.getElementById('content'); 1.142 + textNode = document.createTextNode(prefix); 1.143 + testContainer.appendChild(textNode); 1.144 + textNode.appendData(ltr + rtl); 1.145 + yield undefined; 1.146 + } 1.147 + 1.148 + // appendData with non-8bit prefix 1.149 + for (i = 0; i <= 16; i++) { 1.150 + prefix = non8bit; 1.151 + ltr = strMult(is8bit, i); 1.152 + refContainer.innerHTML = prefix + ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; 1.153 + testContainer = testFrame.contentDocument.getElementById('content'); 1.154 + textNode = document.createTextNode(prefix); 1.155 + testContainer.appendChild(textNode); 1.156 + textNode.appendData(ltr + rtl); 1.157 + yield undefined; 1.158 + } 1.159 + 1.160 + for (i = 0; i <= 16; i++) { 1.161 + prefix = non8bit; 1.162 + ltr = non8bit + strMult(is8bit, i); 1.163 + refContainer.innerHTML = prefix + ltr + '<bdo dir="rtl">' + rtl + '</bdo>'; 1.164 + testContainer = testFrame.contentDocument.getElementById('content'); 1.165 + textNode = document.createTextNode(prefix); 1.166 + testContainer.appendChild(textNode); 1.167 + textNode.appendData(ltr + rtl); 1.168 + yield undefined; 1.169 + } 1.170 +}; 1.171 + 1.172 +var tests = runTests(); 1.173 + 1.174 +</script> 1.175 +</pre> 1.176 +</body> 1.177 +</html>