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 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=459470 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>XMLHttpRequest return document URIs</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 10 | <base href="http://example.org/"> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | <a target="_blank" |
michael@0 | 14 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=459470">Mozilla Bug 459470</a><br /> |
michael@0 | 15 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=859095">Mozilla Bug 859095</a> |
michael@0 | 16 | |
michael@0 | 17 | <p id="display"> |
michael@0 | 18 | <iframe id=loader></iframe> |
michael@0 | 19 | </p> |
michael@0 | 20 | <div id="content" style="display: none"> |
michael@0 | 21 | |
michael@0 | 22 | </div> |
michael@0 | 23 | <pre id="test"> |
michael@0 | 24 | <script class="testbody" type="application/javascript;version=1.8"> |
michael@0 | 25 | |
michael@0 | 26 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 27 | |
michael@0 | 28 | gen = runTest(); |
michael@0 | 29 | gen.next(); |
michael@0 | 30 | |
michael@0 | 31 | function testXMLDocURI(aDoc, aExpects) { |
michael@0 | 32 | is(aDoc.documentURI, aExpects.documentURI, "wrong url"); |
michael@0 | 33 | is(aDoc.baseURI, aExpects.baseURI, "wrong base"); |
michael@0 | 34 | is(aDoc.documentElement.baseURI, aExpects.elementBaseURI, |
michael@0 | 35 | "wrong base (xml:base)"); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function testChromeXMLDocURI(aDoc, aExpects) { |
michael@0 | 39 | is(aDoc.documentURI, aExpects.documentURI, "wrong url"); |
michael@0 | 40 | is(aDoc.documentURIObject.spec, aExpects.documentURI, |
michael@0 | 41 | "wrong url (.documentObjectURI)"); |
michael@0 | 42 | is(aDoc.baseURI, aExpects.baseURI, "wrong base"); |
michael@0 | 43 | is(aDoc.baseURIObject.spec, aExpects.baseURI, |
michael@0 | 44 | "wrong base (.baseURIObject)"); |
michael@0 | 45 | is(aDoc.documentElement.baseURI, aExpects.elementBaseURI, |
michael@0 | 46 | "wrong base (xml:base)"); |
michael@0 | 47 | is(aDoc.documentElement.baseURIObject.spec, aExpects.elementBaseURI, |
michael@0 | 48 | "wrong base (.baseURIObject, xml:base)"); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | function testHTMLDocURI(aDoc, aExpects) { |
michael@0 | 52 | is(aDoc.documentURI, aExpects.documentURI, "wrong url"); |
michael@0 | 53 | is(aDoc.baseURI, aExpects.baseURI, "wrong base"); |
michael@0 | 54 | |
michael@0 | 55 | var base = aDoc.createElement("base"); |
michael@0 | 56 | var newBaseURI = "http://www.example.com/"; |
michael@0 | 57 | base.href = newBaseURI; |
michael@0 | 58 | aDoc.head.appendChild(base); |
michael@0 | 59 | is(aDoc.baseURI, newBaseURI, "wrong base (after <base> changed)"); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | function testChromeHTMLDocURI(aDoc, aNonChromeBaseURI, aExpects) { |
michael@0 | 63 | is(aDoc.documentURI, aExpects.documentURI, "wrong url"); |
michael@0 | 64 | is(aDoc.documentURIObject.spec, aExpects.documentURI, |
michael@0 | 65 | "wrong url (.documentURIObject)"); |
michael@0 | 66 | is(aDoc.baseURI, aExpects.baseURI, "wrong base"); |
michael@0 | 67 | is(aDoc.baseURIObject.spec, aExpects.baseURI, |
michael@0 | 68 | "wrong url (.baseURIObject)"); |
michael@0 | 69 | |
michael@0 | 70 | aDoc.body.setAttributeNS("http://www.w3.org/XML/1998/namespace", "base", |
michael@0 | 71 | aNonChromeBaseURI); |
michael@0 | 72 | is(aDoc.body.baseURI, aNonChromeBaseURI, |
michael@0 | 73 | "wrong base (doc base and xml:base are same)"); |
michael@0 | 74 | is(aDoc.body.baseURIObject.spec, aNonChromeBaseURI, |
michael@0 | 75 | "wrong base (.baseURIObject, doc base and xml:base are same)") |
michael@0 | 76 | var attr = aDoc.getElementById("data").getAttributeNode("id"); |
michael@0 | 77 | is(attr.baseURI, aNonChromeBaseURI, |
michael@0 | 78 | "wrong attr base (doc base and xml:base are same)") |
michael@0 | 79 | is(attr.baseURIObject.spec, aNonChromeBaseURI, |
michael@0 | 80 | "wrong attr base (.baseURIObject, doc base and xml:base are same)") |
michael@0 | 81 | |
michael@0 | 82 | var base = aDoc.createElement("base"); |
michael@0 | 83 | var newBaseURI = "http://www.example.com/"; |
michael@0 | 84 | base.href = newBaseURI; |
michael@0 | 85 | aDoc.head.appendChild(base); |
michael@0 | 86 | is(aDoc.baseURI, newBaseURI, "wrong base (after <base> changed)"); |
michael@0 | 87 | is(aDoc.baseURIObject.spec, newBaseURI, |
michael@0 | 88 | "wrong base (.baseURIObject, after <base> changed)"); |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | function testCloneDocURI(aDoc) { |
michael@0 | 92 | var clone = aDoc.cloneNode(true); |
michael@0 | 93 | is(clone.documentURI, aDoc.documentURI, "wrong url (clone)"); |
michael@0 | 94 | is(clone.baseURI, aDoc.baseURI, "wrong base (clone)"); |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | function runTest() { |
michael@0 | 98 | is(document.baseURI, "http://example.org/", "wrong doc baseURI"); |
michael@0 | 99 | |
michael@0 | 100 | // use content XHR and access URI properties from content privileged script |
michael@0 | 101 | xhr = new XMLHttpRequest; |
michael@0 | 102 | xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml"); |
michael@0 | 103 | xhr.onreadystatechange = function(e) { |
michael@0 | 104 | if (!xhr.responseXML) { |
michael@0 | 105 | return; |
michael@0 | 106 | } |
michael@0 | 107 | var expects = { |
michael@0 | 108 | documentURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml", |
michael@0 | 109 | baseURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml", |
michael@0 | 110 | elementBaseURI: "http://www.example.com/" |
michael@0 | 111 | }; |
michael@0 | 112 | testXMLDocURI(xhr.responseXML, expects); |
michael@0 | 113 | if (xhr.readyState == 4) { |
michael@0 | 114 | gen.next(); |
michael@0 | 115 | } |
michael@0 | 116 | }; |
michael@0 | 117 | xhr.send(); |
michael@0 | 118 | yield undefined; |
michael@0 | 119 | |
michael@0 | 120 | xhr = new XMLHttpRequest; |
michael@0 | 121 | xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html"); |
michael@0 | 122 | xhr.responseType = "document"; |
michael@0 | 123 | xhr.onreadystatechange = function(e) { |
michael@0 | 124 | if (!xhr.response) { |
michael@0 | 125 | return; |
michael@0 | 126 | } |
michael@0 | 127 | var expects = { |
michael@0 | 128 | documentURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html", |
michael@0 | 129 | baseURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html" |
michael@0 | 130 | }; |
michael@0 | 131 | testHTMLDocURI(xhr.response, expects); |
michael@0 | 132 | if (xhr.readyState == 4) { |
michael@0 | 133 | gen.next(); |
michael@0 | 134 | } |
michael@0 | 135 | }; |
michael@0 | 136 | xhr.send(); |
michael@0 | 137 | yield undefined; |
michael@0 | 138 | |
michael@0 | 139 | xhr = new XMLHttpRequest; |
michael@0 | 140 | xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.text"); |
michael@0 | 141 | xhr.onreadystatechange = function(e) { |
michael@0 | 142 | is(xhr.responseXML, null, "should not have document"); |
michael@0 | 143 | if (xhr.readyState == 4) { |
michael@0 | 144 | gen.next(); |
michael@0 | 145 | } |
michael@0 | 146 | }; |
michael@0 | 147 | xhr.send(); |
michael@0 | 148 | yield undefined; |
michael@0 | 149 | |
michael@0 | 150 | xhr = new XMLHttpRequest; |
michael@0 | 151 | xhr.open("GET", "http://example.com/tests/content/base/test/file_XHRDocURI.xml"); |
michael@0 | 152 | xhr.onreadystatechange = function(e) { |
michael@0 | 153 | if (!xhr.responseXML) { |
michael@0 | 154 | return; |
michael@0 | 155 | } |
michael@0 | 156 | var expects = { |
michael@0 | 157 | documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml", |
michael@0 | 158 | baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml", |
michael@0 | 159 | elementBaseURI: "http://www.example.com/" |
michael@0 | 160 | }; |
michael@0 | 161 | testXMLDocURI(xhr.responseXML, expects); |
michael@0 | 162 | if (xhr.readyState == 4) { |
michael@0 | 163 | gen.next(); |
michael@0 | 164 | } |
michael@0 | 165 | }; |
michael@0 | 166 | xhr.send(); |
michael@0 | 167 | yield undefined; |
michael@0 | 168 | |
michael@0 | 169 | xhr = new XMLHttpRequest; |
michael@0 | 170 | xhr.open("GET", "http://example.com/tests/content/base/test/file_XHRDocURI.html"); |
michael@0 | 171 | xhr.responseType = "document"; |
michael@0 | 172 | xhr.onreadystatechange = function(e) { |
michael@0 | 173 | if (!xhr.response) { |
michael@0 | 174 | return; |
michael@0 | 175 | } |
michael@0 | 176 | var expects = { |
michael@0 | 177 | documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html", |
michael@0 | 178 | baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html" |
michael@0 | 179 | }; |
michael@0 | 180 | testHTMLDocURI(xhr.response, expects); |
michael@0 | 181 | if (xhr.readyState == 4) { |
michael@0 | 182 | gen.next(); |
michael@0 | 183 | } |
michael@0 | 184 | }; |
michael@0 | 185 | xhr.send(); |
michael@0 | 186 | yield undefined; |
michael@0 | 187 | |
michael@0 | 188 | xhr = new XMLHttpRequest; |
michael@0 | 189 | xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.sjs?url=http://example.com/tests/content/base/test/file_XHRDocURI.xml"); |
michael@0 | 190 | xhr.onreadystatechange = function(e) { |
michael@0 | 191 | if (!xhr.responseXML) { |
michael@0 | 192 | return; |
michael@0 | 193 | } |
michael@0 | 194 | var expects = { |
michael@0 | 195 | documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml", |
michael@0 | 196 | baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml", |
michael@0 | 197 | elementBaseURI: "http://www.example.com/" |
michael@0 | 198 | }; |
michael@0 | 199 | testXMLDocURI(xhr.responseXML, expects); |
michael@0 | 200 | if (xhr.readyState == 4) { |
michael@0 | 201 | gen.next(); |
michael@0 | 202 | } |
michael@0 | 203 | }; |
michael@0 | 204 | xhr.send(); |
michael@0 | 205 | yield undefined; |
michael@0 | 206 | |
michael@0 | 207 | xhr = new XMLHttpRequest; |
michael@0 | 208 | xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.sjs?url=http://example.com/tests/content/base/test/file_XHRDocURI.html"); |
michael@0 | 209 | xhr.responseType = "document"; |
michael@0 | 210 | xhr.onreadystatechange = function(e) { |
michael@0 | 211 | if (!xhr.response) { |
michael@0 | 212 | return; |
michael@0 | 213 | } |
michael@0 | 214 | var expects = { |
michael@0 | 215 | documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html", |
michael@0 | 216 | baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html" |
michael@0 | 217 | }; |
michael@0 | 218 | testHTMLDocURI(xhr.response, expects); |
michael@0 | 219 | if (xhr.readyState == 4) { |
michael@0 | 220 | gen.next(); |
michael@0 | 221 | } |
michael@0 | 222 | }; |
michael@0 | 223 | xhr.send(); |
michael@0 | 224 | yield undefined; |
michael@0 | 225 | |
michael@0 | 226 | xhr = new XMLHttpRequest; |
michael@0 | 227 | xhr.open("GET", "http://example.com/tests/content/base/test/file_XHRDocURI.text"); |
michael@0 | 228 | xhr.onreadystatechange = function(e) { |
michael@0 | 229 | is(xhr.responseXML, null, "should not have document"); |
michael@0 | 230 | if (xhr.readyState == 4) { |
michael@0 | 231 | gen.next(); |
michael@0 | 232 | } |
michael@0 | 233 | }; |
michael@0 | 234 | xhr.send(); |
michael@0 | 235 | yield undefined; |
michael@0 | 236 | |
michael@0 | 237 | |
michael@0 | 238 | // use content XHR and access URI properties from chrome privileged script |
michael@0 | 239 | |
michael@0 | 240 | xhr = new XMLHttpRequest; |
michael@0 | 241 | xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml"); |
michael@0 | 242 | xhr.onreadystatechange = function(e) { |
michael@0 | 243 | if (!xhr.responseXML) { |
michael@0 | 244 | return; |
michael@0 | 245 | } |
michael@0 | 246 | var expects = { |
michael@0 | 247 | documentURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml", |
michael@0 | 248 | baseURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml", |
michael@0 | 249 | elementBaseURI: "http://www.example.com/" |
michael@0 | 250 | }; |
michael@0 | 251 | var xml = SpecialPowers.wrap(xhr.responseXML); |
michael@0 | 252 | testChromeXMLDocURI(xml, expects); |
michael@0 | 253 | testCloneDocURI(xml); |
michael@0 | 254 | if (xhr.readyState == 4) { |
michael@0 | 255 | gen.next(); |
michael@0 | 256 | } |
michael@0 | 257 | }; |
michael@0 | 258 | xhr.send(); |
michael@0 | 259 | yield undefined; |
michael@0 | 260 | |
michael@0 | 261 | xhr = new XMLHttpRequest; |
michael@0 | 262 | xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html"); |
michael@0 | 263 | xhr.responseType = "document"; |
michael@0 | 264 | xhr.onreadystatechange = function(e) { |
michael@0 | 265 | if (!xhr.response) { |
michael@0 | 266 | return; |
michael@0 | 267 | } |
michael@0 | 268 | var expects = { |
michael@0 | 269 | documentURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html", |
michael@0 | 270 | baseURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html" |
michael@0 | 271 | }; |
michael@0 | 272 | var doc = SpecialPowers.wrap(xhr.response); |
michael@0 | 273 | testChromeHTMLDocURI(doc, "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html", expects); |
michael@0 | 274 | testCloneDocURI(doc); |
michael@0 | 275 | if (xhr.readyState == 4) { |
michael@0 | 276 | gen.next(); |
michael@0 | 277 | } |
michael@0 | 278 | }; |
michael@0 | 279 | xhr.send(); |
michael@0 | 280 | yield undefined; |
michael@0 | 281 | |
michael@0 | 282 | xhr = new XMLHttpRequest; |
michael@0 | 283 | xhr.open("GET", "http://example.com/tests/content/base/test/file_XHRDocURI.xml"); |
michael@0 | 284 | xhr.onreadystatechange = function(e) { |
michael@0 | 285 | if (!xhr.responseXML) { |
michael@0 | 286 | return; |
michael@0 | 287 | } |
michael@0 | 288 | var expects = { |
michael@0 | 289 | documentURI: document.documentURI, |
michael@0 | 290 | baseURI: document.baseURI, |
michael@0 | 291 | elementBaseURI: "http://www.example.com/" |
michael@0 | 292 | }; |
michael@0 | 293 | var xml = SpecialPowers.wrap(xhr.responseXML); |
michael@0 | 294 | testChromeXMLDocURI(xml, expects); |
michael@0 | 295 | testCloneDocURI(xml); |
michael@0 | 296 | if (xhr.readyState == 4) { |
michael@0 | 297 | gen.next(); |
michael@0 | 298 | } |
michael@0 | 299 | }; |
michael@0 | 300 | xhr.send(); |
michael@0 | 301 | yield undefined; |
michael@0 | 302 | |
michael@0 | 303 | xhr = new XMLHttpRequest; |
michael@0 | 304 | xhr.open("GET", "http://example.com/tests/content/base/test/file_XHRDocURI.html"); |
michael@0 | 305 | xhr.responseType = "document"; |
michael@0 | 306 | xhr.onreadystatechange = function(e) { |
michael@0 | 307 | if (!xhr.response) { |
michael@0 | 308 | return; |
michael@0 | 309 | } |
michael@0 | 310 | var expects = { |
michael@0 | 311 | documentURI: document.documentURI, |
michael@0 | 312 | baseURI: document.baseURI |
michael@0 | 313 | }; |
michael@0 | 314 | var doc = SpecialPowers.wrap(xhr.response); |
michael@0 | 315 | testChromeHTMLDocURI(doc, "http://example.com/tests/content/base/test/file_XHRDocURI.html", expects); |
michael@0 | 316 | testCloneDocURI(doc); |
michael@0 | 317 | if (xhr.readyState == 4) { |
michael@0 | 318 | gen.next(); |
michael@0 | 319 | } |
michael@0 | 320 | }; |
michael@0 | 321 | xhr.send(); |
michael@0 | 322 | yield undefined; |
michael@0 | 323 | |
michael@0 | 324 | xhr = new XMLHttpRequest; |
michael@0 | 325 | xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.sjs?url=http://example.com/tests/content/base/test/file_XHRDocURI.xml"); |
michael@0 | 326 | xhr.onreadystatechange = function(e) { |
michael@0 | 327 | if (!xhr.responseXML) { |
michael@0 | 328 | return; |
michael@0 | 329 | } |
michael@0 | 330 | var expects = { |
michael@0 | 331 | documentURI: document.documentURI, |
michael@0 | 332 | baseURI: document.baseURI, |
michael@0 | 333 | elementBaseURI: "http://www.example.com/" |
michael@0 | 334 | }; |
michael@0 | 335 | var xml = SpecialPowers.wrap(xhr.responseXML); |
michael@0 | 336 | testChromeXMLDocURI(xml, expects); |
michael@0 | 337 | testCloneDocURI(xml); |
michael@0 | 338 | if (xhr.readyState == 4) { |
michael@0 | 339 | gen.next(); |
michael@0 | 340 | } |
michael@0 | 341 | }; |
michael@0 | 342 | xhr.send(); |
michael@0 | 343 | yield undefined; |
michael@0 | 344 | |
michael@0 | 345 | xhr = new XMLHttpRequest; |
michael@0 | 346 | xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.sjs?url=http://example.com/tests/content/base/test/file_XHRDocURI.html"); |
michael@0 | 347 | xhr.responseType = "document"; |
michael@0 | 348 | xhr.onreadystatechange = function(e) { |
michael@0 | 349 | if (!xhr.response) { |
michael@0 | 350 | return; |
michael@0 | 351 | } |
michael@0 | 352 | var expects = { |
michael@0 | 353 | documentURI: document.documentURI, |
michael@0 | 354 | baseURI: document.baseURI |
michael@0 | 355 | }; |
michael@0 | 356 | var doc = SpecialPowers.wrap(xhr.response); |
michael@0 | 357 | testChromeHTMLDocURI(doc, "http://example.com/tests/content/base/test/file_XHRDocURI.html", expects); |
michael@0 | 358 | testCloneDocURI(doc); |
michael@0 | 359 | if (xhr.readyState == 4) { |
michael@0 | 360 | gen.next(); |
michael@0 | 361 | } |
michael@0 | 362 | }; |
michael@0 | 363 | xhr.send(); |
michael@0 | 364 | yield undefined; |
michael@0 | 365 | |
michael@0 | 366 | |
michael@0 | 367 | // use chrome XHR and access URI properties from chrome privileged script |
michael@0 | 368 | SpecialPowers.addPermission("systemXHR", true, document); |
michael@0 | 369 | xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true}); |
michael@0 | 370 | xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml"); |
michael@0 | 371 | xhr.onreadystatechange = function(e) { |
michael@0 | 372 | if (!xhr.responseXML) { |
michael@0 | 373 | return; |
michael@0 | 374 | } |
michael@0 | 375 | var expects = { |
michael@0 | 376 | documentURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml", |
michael@0 | 377 | baseURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.xml", |
michael@0 | 378 | elementBaseURI: "http://www.example.com/" |
michael@0 | 379 | }; |
michael@0 | 380 | var xml = SpecialPowers.wrap(xhr.responseXML); |
michael@0 | 381 | testChromeXMLDocURI(xml, expects); |
michael@0 | 382 | if (xhr.readyState == 4) { |
michael@0 | 383 | gen.next(); |
michael@0 | 384 | } |
michael@0 | 385 | }; |
michael@0 | 386 | xhr.send(); |
michael@0 | 387 | yield undefined; |
michael@0 | 388 | |
michael@0 | 389 | xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true}); |
michael@0 | 390 | xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html"); |
michael@0 | 391 | xhr.responseType = "document"; |
michael@0 | 392 | xhr.onreadystatechange = function(e) { |
michael@0 | 393 | if (!xhr.response) { |
michael@0 | 394 | return; |
michael@0 | 395 | } |
michael@0 | 396 | var expects = { |
michael@0 | 397 | documentURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html", |
michael@0 | 398 | baseURI: "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html" |
michael@0 | 399 | }; |
michael@0 | 400 | var doc = SpecialPowers.wrap(xhr.response); |
michael@0 | 401 | testChromeHTMLDocURI(doc, "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.html", expects); |
michael@0 | 402 | if (xhr.readyState == 4) { |
michael@0 | 403 | gen.next(); |
michael@0 | 404 | } |
michael@0 | 405 | }; |
michael@0 | 406 | xhr.send(); |
michael@0 | 407 | yield undefined; |
michael@0 | 408 | |
michael@0 | 409 | xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true}); |
michael@0 | 410 | xhr.open("GET", "http://example.com/tests/content/base/test/file_XHRDocURI.xml"); |
michael@0 | 411 | xhr.onreadystatechange = function(e) { |
michael@0 | 412 | if (!xhr.responseXML) { |
michael@0 | 413 | return; |
michael@0 | 414 | } |
michael@0 | 415 | var expects = { |
michael@0 | 416 | documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml", |
michael@0 | 417 | baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml", |
michael@0 | 418 | elementBaseURI: "http://www.example.com/" |
michael@0 | 419 | }; |
michael@0 | 420 | var xml = SpecialPowers.wrap(xhr.responseXML); |
michael@0 | 421 | testChromeXMLDocURI(xml, expects); |
michael@0 | 422 | if (xhr.readyState == 4) { |
michael@0 | 423 | gen.next(); |
michael@0 | 424 | } |
michael@0 | 425 | }; |
michael@0 | 426 | xhr.send(); |
michael@0 | 427 | yield undefined; |
michael@0 | 428 | |
michael@0 | 429 | xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true}); |
michael@0 | 430 | xhr.open("GET", "http://example.com/tests/content/base/test/file_XHRDocURI.html"); |
michael@0 | 431 | xhr.responseType = "document"; |
michael@0 | 432 | xhr.onreadystatechange = function(e) { |
michael@0 | 433 | if (!xhr.response) { |
michael@0 | 434 | return; |
michael@0 | 435 | } |
michael@0 | 436 | var expects = { |
michael@0 | 437 | documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html", |
michael@0 | 438 | baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html" |
michael@0 | 439 | }; |
michael@0 | 440 | var doc = SpecialPowers.wrap(xhr.response); |
michael@0 | 441 | testChromeHTMLDocURI(doc, "http://example.com/tests/content/base/test/file_XHRDocURI.html", expects); |
michael@0 | 442 | if (xhr.readyState == 4) { |
michael@0 | 443 | gen.next(); |
michael@0 | 444 | } |
michael@0 | 445 | }; |
michael@0 | 446 | xhr.send(); |
michael@0 | 447 | yield undefined; |
michael@0 | 448 | |
michael@0 | 449 | xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true}); |
michael@0 | 450 | xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.sjs?url=http://example.com/tests/content/base/test/file_XHRDocURI.xml"); |
michael@0 | 451 | xhr.onreadystatechange = function(e) { |
michael@0 | 452 | if (!xhr.responseXML) { |
michael@0 | 453 | return; |
michael@0 | 454 | } |
michael@0 | 455 | var expects = { |
michael@0 | 456 | documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml", |
michael@0 | 457 | baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.xml", |
michael@0 | 458 | elementBaseURI: "http://www.example.com/" |
michael@0 | 459 | }; |
michael@0 | 460 | var xml = SpecialPowers.wrap(xhr.responseXML); |
michael@0 | 461 | testChromeXMLDocURI(xml, expects); |
michael@0 | 462 | if (xhr.readyState == 4) { |
michael@0 | 463 | gen.next(); |
michael@0 | 464 | } |
michael@0 | 465 | }; |
michael@0 | 466 | xhr.send(); |
michael@0 | 467 | yield undefined; |
michael@0 | 468 | |
michael@0 | 469 | xhr = new XMLHttpRequest({mozAnon: false, mozSystem: true}); |
michael@0 | 470 | xhr.open("GET", "http://mochi.test:8888/tests/content/base/test/file_XHRDocURI.sjs?url=http://example.com/tests/content/base/test/file_XHRDocURI.html"); |
michael@0 | 471 | xhr.responseType = "document"; |
michael@0 | 472 | xhr.onreadystatechange = function(e) { |
michael@0 | 473 | if (!xhr.response) { |
michael@0 | 474 | return; |
michael@0 | 475 | } |
michael@0 | 476 | var expects = { |
michael@0 | 477 | documentURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html", |
michael@0 | 478 | baseURI: "http://example.com/tests/content/base/test/file_XHRDocURI.html" |
michael@0 | 479 | }; |
michael@0 | 480 | var doc = SpecialPowers.wrap(xhr.response); |
michael@0 | 481 | testChromeHTMLDocURI(doc, "http://example.com/tests/content/base/test/file_XHRDocURI.html", expects); |
michael@0 | 482 | if (xhr.readyState == 4) { |
michael@0 | 483 | gen.next(); |
michael@0 | 484 | } |
michael@0 | 485 | }; |
michael@0 | 486 | xhr.send(); |
michael@0 | 487 | yield undefined; |
michael@0 | 488 | |
michael@0 | 489 | SimpleTest.finish(); |
michael@0 | 490 | SpecialPowers.removePermission("systemXHR", document); |
michael@0 | 491 | yield undefined; |
michael@0 | 492 | } |
michael@0 | 493 | |
michael@0 | 494 | </script> |
michael@0 | 495 | </pre> |
michael@0 | 496 | </body> |
michael@0 | 497 | </html> |