content/base/test/test_bug682592.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

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

mercurial