Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test for Async Auth Prompt</title> |
michael@0 | 5 | <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> |
michael@0 | 6 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 7 | <script type="text/javascript" src="prompt_common.js"></script> |
michael@0 | 8 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 9 | |
michael@0 | 10 | <script class="testbody" type="text/javascript"> |
michael@0 | 11 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 12 | |
michael@0 | 13 | // Class monitoring number of open dialog windows |
michael@0 | 14 | // It checks there is always open just a single dialog per application |
michael@0 | 15 | function dialogMonitor() { |
michael@0 | 16 | var observerService = SpecialPowers.Cc["@mozilla.org/observer-service;1"] |
michael@0 | 17 | .getService(Ci.nsIObserverService); |
michael@0 | 18 | observerService.addObserver(this, "domwindowopened", false); |
michael@0 | 19 | observerService.addObserver(this, "domwindowclosed", false); |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | /* |
michael@0 | 23 | * As documented in Bug 718543, checking equality of objects pulled |
michael@0 | 24 | * from SpecialPowers-wrapped objects is unreliable. Because of that, |
michael@0 | 25 | * `dialogMonitor` now tracks the number of open windows rather than |
michael@0 | 26 | * specific window objects. |
michael@0 | 27 | * |
michael@0 | 28 | * NB: Because the constructor (above) adds |this| directly as an observer, |
michael@0 | 29 | * we need to do SpecialPowers.wrapCallbackObject directly on the prototype. |
michael@0 | 30 | */ |
michael@0 | 31 | dialogMonitor.prototype = SpecialPowers.wrapCallbackObject({ |
michael@0 | 32 | windowsOpen : 0, |
michael@0 | 33 | windowsRegistered : 0, |
michael@0 | 34 | |
michael@0 | 35 | QueryInterface : function (iid) { |
michael@0 | 36 | const interfaces = [Ci.nsIObserver, Ci.nsISupports]; |
michael@0 | 37 | |
michael@0 | 38 | if (!interfaces.some( function(v) { return iid.equals(v) } )) |
michael@0 | 39 | throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE; |
michael@0 | 40 | return this; |
michael@0 | 41 | }, |
michael@0 | 42 | |
michael@0 | 43 | observe: function(subject, topic, data) { |
michael@0 | 44 | if (topic === "domwindowopened") { |
michael@0 | 45 | this.windowsOpen++; |
michael@0 | 46 | this.windowsRegistered++; |
michael@0 | 47 | return; |
michael@0 | 48 | } |
michael@0 | 49 | if (topic === "domwindowclosed") { |
michael@0 | 50 | this.windowsOpen--; |
michael@0 | 51 | return; |
michael@0 | 52 | } |
michael@0 | 53 | }, |
michael@0 | 54 | |
michael@0 | 55 | shutdown: function() { |
michael@0 | 56 | var observerService = SpecialPowers.Cc["@mozilla.org/observer-service;1"] |
michael@0 | 57 | .getService(Ci.nsIObserverService); |
michael@0 | 58 | observerService.removeObserver(this, "domwindowopened"); |
michael@0 | 59 | observerService.removeObserver(this, "domwindowclosed"); |
michael@0 | 60 | }, |
michael@0 | 61 | |
michael@0 | 62 | reset: function() { |
michael@0 | 63 | this.windowsOpen = 0; |
michael@0 | 64 | this.windowsRegistered = 0; |
michael@0 | 65 | } |
michael@0 | 66 | }); |
michael@0 | 67 | |
michael@0 | 68 | var monitor = new dialogMonitor(); |
michael@0 | 69 | |
michael@0 | 70 | var pwmgr, logins = []; |
michael@0 | 71 | |
michael@0 | 72 | function initLogins(pi) { |
michael@0 | 73 | pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"] |
michael@0 | 74 | .getService(Ci.nsILoginManager); |
michael@0 | 75 | |
michael@0 | 76 | function addLogin(host, realm, user, pass) { |
michael@0 | 77 | var login = SpecialPowers.Cc["@mozilla.org/login-manager/loginInfo;1"] |
michael@0 | 78 | .createInstance(Ci.nsILoginInfo); |
michael@0 | 79 | login.init(host, null, realm, user, pass, "", ""); |
michael@0 | 80 | pwmgr.addLogin(login); |
michael@0 | 81 | logins.push(login); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | var mozproxy = "moz-proxy://" + |
michael@0 | 85 | SpecialPowers.wrap(pi).host + ":" + |
michael@0 | 86 | SpecialPowers.wrap(pi).port; |
michael@0 | 87 | |
michael@0 | 88 | addLogin(mozproxy, "proxy_realm", |
michael@0 | 89 | "proxy_user", "proxy_pass"); |
michael@0 | 90 | addLogin(mozproxy, "proxy_realm2", |
michael@0 | 91 | "proxy_user2", "proxy_pass2"); |
michael@0 | 92 | addLogin(mozproxy, "proxy_realm3", |
michael@0 | 93 | "proxy_user3", "proxy_pass3"); |
michael@0 | 94 | addLogin(mozproxy, "proxy_realm4", |
michael@0 | 95 | "proxy_user4", "proxy_pass4"); |
michael@0 | 96 | addLogin(mozproxy, "proxy_realm5", |
michael@0 | 97 | "proxy_user5", "proxy_pass5"); |
michael@0 | 98 | addLogin("http://example.com", "mochirealm", |
michael@0 | 99 | "user1name", "user1pass"); |
michael@0 | 100 | addLogin("http://example.org", "mochirealm2", |
michael@0 | 101 | "user2name", "user2pass"); |
michael@0 | 102 | addLogin("http://example.com", "mochirealm3", |
michael@0 | 103 | "user3name", "user3pass"); |
michael@0 | 104 | addLogin("http://example.com", "mochirealm4", |
michael@0 | 105 | "user4name", "user4pass"); |
michael@0 | 106 | addLogin("http://example.com", "mochirealm5", |
michael@0 | 107 | "user5name", "user5pass"); |
michael@0 | 108 | addLogin("http://example.com", "mochirealm6", |
michael@0 | 109 | "user6name", "user6pass"); |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | function finishTest() { |
michael@0 | 113 | ok(true, "finishTest removing testing logins..."); |
michael@0 | 114 | for (i in logins) |
michael@0 | 115 | pwmgr.removeLogin(logins[i]); |
michael@0 | 116 | |
michael@0 | 117 | var authMgr = SpecialPowers.Cc['@mozilla.org/network/http-auth-manager;1'] |
michael@0 | 118 | .getService(Ci.nsIHttpAuthManager); |
michael@0 | 119 | authMgr.clearAll(); |
michael@0 | 120 | |
michael@0 | 121 | monitor.shutdown(); |
michael@0 | 122 | SimpleTest.finish(); |
michael@0 | 123 | } |
michael@0 | 124 | |
michael@0 | 125 | var resolveCallback = SpecialPowers.wrapCallbackObject({ |
michael@0 | 126 | QueryInterface : function (iid) { |
michael@0 | 127 | const interfaces = [Ci.nsIProtocolProxyCallback, Ci.nsISupports]; |
michael@0 | 128 | |
michael@0 | 129 | if (!interfaces.some( function(v) { return iid.equals(v) } )) |
michael@0 | 130 | throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE; |
michael@0 | 131 | return this; |
michael@0 | 132 | }, |
michael@0 | 133 | |
michael@0 | 134 | onProxyAvailable : function (req, uri, pi, status) { |
michael@0 | 135 | initLogins(pi); |
michael@0 | 136 | doTest(testNum); |
michael@0 | 137 | } |
michael@0 | 138 | }); |
michael@0 | 139 | |
michael@0 | 140 | function startup() { |
michael@0 | 141 | //need to allow for arbitrary network servers defined in PAC instead of a hardcoded moz-proxy. |
michael@0 | 142 | var ios = SpecialPowers.Cc["@mozilla.org/network/io-service;1"] |
michael@0 | 143 | .getService(SpecialPowers.Ci.nsIIOService); |
michael@0 | 144 | |
michael@0 | 145 | var pps = SpecialPowers.Cc["@mozilla.org/network/protocol-proxy-service;1"] |
michael@0 | 146 | .getService(); |
michael@0 | 147 | |
michael@0 | 148 | var uri = ios.newURI("http://example.com", null, null); |
michael@0 | 149 | pps.asyncResolve(uri, 0, resolveCallback); |
michael@0 | 150 | } |
michael@0 | 151 | |
michael@0 | 152 | // --------------- Test loop spin ---------------- |
michael@0 | 153 | var testNum = 1; |
michael@0 | 154 | var iframe1; |
michael@0 | 155 | var iframe2a; |
michael@0 | 156 | var iframe2b; |
michael@0 | 157 | window.onload = function () { |
michael@0 | 158 | iframe1 = document.getElementById("iframe1"); |
michael@0 | 159 | iframe2a = document.getElementById("iframe2a"); |
michael@0 | 160 | iframe2b = document.getElementById("iframe2b"); |
michael@0 | 161 | iframe1.onload = onFrameLoad; |
michael@0 | 162 | iframe2a.onload = onFrameLoad; |
michael@0 | 163 | iframe2b.onload = onFrameLoad; |
michael@0 | 164 | |
michael@0 | 165 | startup(); |
michael@0 | 166 | } |
michael@0 | 167 | |
michael@0 | 168 | var expectedLoads; |
michael@0 | 169 | var expectedDialogs; |
michael@0 | 170 | function onFrameLoad() |
michael@0 | 171 | { |
michael@0 | 172 | if (--expectedLoads == 0) { |
michael@0 | 173 | // All pages expected to load has loaded, continue with the next test |
michael@0 | 174 | ok(true, "Expected frames loaded"); |
michael@0 | 175 | |
michael@0 | 176 | doCheck(testNum); |
michael@0 | 177 | monitor.reset(); |
michael@0 | 178 | |
michael@0 | 179 | testNum++; |
michael@0 | 180 | doTest(testNum); |
michael@0 | 181 | } |
michael@0 | 182 | } |
michael@0 | 183 | |
michael@0 | 184 | function doTest(testNum) |
michael@0 | 185 | { |
michael@0 | 186 | /* |
michael@0 | 187 | * These contentDocument variables are located here, |
michael@0 | 188 | * rather than in the global scope, because SpecialPowers threw |
michael@0 | 189 | * errors (complaining that the objects were deleted) |
michael@0 | 190 | * when these were in the global scope. |
michael@0 | 191 | */ |
michael@0 | 192 | var iframe1Doc = SpecialPowers.wrap(iframe1).contentDocument; |
michael@0 | 193 | var iframe2aDoc = SpecialPowers.wrap(iframe2a).contentDocument; |
michael@0 | 194 | var iframe2bDoc = SpecialPowers.wrap(iframe2b).contentDocument; |
michael@0 | 195 | var exampleCom = "http://example.com/tests/toolkit/components/passwordmgr/test/"; |
michael@0 | 196 | var exampleOrg = "http://example.org/tests/toolkit/components/passwordmgr/test/"; |
michael@0 | 197 | |
michael@0 | 198 | switch (testNum) |
michael@0 | 199 | { |
michael@0 | 200 | case 1: |
michael@0 | 201 | // Load through a single proxy with authentication required 3 different |
michael@0 | 202 | // pages, first with one login, other two with their own different login. |
michael@0 | 203 | // We expect to show just a single dialog for proxy authentication and |
michael@0 | 204 | // then two dialogs to authenticate to login 1 and then login 2. |
michael@0 | 205 | ok(true, "doTest testNum 1"); |
michael@0 | 206 | expectedLoads = 3; |
michael@0 | 207 | expectedDialogs = 3; |
michael@0 | 208 | iframe1.src = exampleCom + "authenticate.sjs?"+ |
michael@0 | 209 | "r=1&"+ |
michael@0 | 210 | "user=user1name&"+ |
michael@0 | 211 | "pass=user1pass&"+ |
michael@0 | 212 | "realm=mochirealm&"+ |
michael@0 | 213 | "proxy_user=proxy_user&"+ |
michael@0 | 214 | "proxy_pass=proxy_pass&"+ |
michael@0 | 215 | "proxy_realm=proxy_realm"; |
michael@0 | 216 | iframe2a.src = exampleOrg + "authenticate.sjs?"+ |
michael@0 | 217 | "r=2&"+ |
michael@0 | 218 | "user=user2name&"+ |
michael@0 | 219 | "pass=user2pass&"+ |
michael@0 | 220 | "realm=mochirealm2&"+ |
michael@0 | 221 | "proxy_user=proxy_user&"+ |
michael@0 | 222 | "proxy_pass=proxy_pass&"+ |
michael@0 | 223 | "proxy_realm=proxy_realm"; |
michael@0 | 224 | iframe2b.src = exampleOrg + "authenticate.sjs?"+ |
michael@0 | 225 | "r=3&"+ |
michael@0 | 226 | "user=user2name&"+ |
michael@0 | 227 | "pass=user2pass&"+ |
michael@0 | 228 | "realm=mochirealm2&"+ |
michael@0 | 229 | "proxy_user=proxy_user&"+ |
michael@0 | 230 | "proxy_pass=proxy_pass&"+ |
michael@0 | 231 | "proxy_realm=proxy_realm"; |
michael@0 | 232 | break; |
michael@0 | 233 | |
michael@0 | 234 | case 2: |
michael@0 | 235 | // Load an iframe with 3 subpages all requiring the same login through |
michael@0 | 236 | // anuthenticated proxy. We expect 2 dialogs, proxy authentication |
michael@0 | 237 | // and web authentication. |
michael@0 | 238 | ok(true, "doTest testNum 2"); |
michael@0 | 239 | expectedLoads = 3; |
michael@0 | 240 | expectedDialogs = 2; |
michael@0 | 241 | iframe1.src = exampleCom + "subtst_prompt_async.html"; |
michael@0 | 242 | iframe2a.src = "about:blank"; |
michael@0 | 243 | iframe2b.src = "about:blank"; |
michael@0 | 244 | break; |
michael@0 | 245 | |
michael@0 | 246 | case 3: |
michael@0 | 247 | // Load in the iframe page through unauthenticated proxy |
michael@0 | 248 | // and discard the proxy authentication. We expect to see |
michael@0 | 249 | // unauthenticated page content and just a single dialog. |
michael@0 | 250 | ok(true, "doTest testNum 3"); |
michael@0 | 251 | expectedLoads = 1; |
michael@0 | 252 | expectedDialogs = 1; |
michael@0 | 253 | iframe1.src = exampleCom + "authenticate.sjs?"+ |
michael@0 | 254 | "user=user4name&"+ |
michael@0 | 255 | "pass=user4pass&"+ |
michael@0 | 256 | "realm=mochirealm4&"+ |
michael@0 | 257 | "proxy_user=proxy_user3&"+ |
michael@0 | 258 | "proxy_pass=proxy_pass3&"+ |
michael@0 | 259 | "proxy_realm=proxy_realm3"; |
michael@0 | 260 | break; |
michael@0 | 261 | |
michael@0 | 262 | case 4: |
michael@0 | 263 | // Reload the frame from previous step and pass the proxy authentication |
michael@0 | 264 | // but cancel the WWW authentication. We should get the proxy=ok and WWW=fail |
michael@0 | 265 | // content as a result. |
michael@0 | 266 | ok(true, "doTest testNum 4"); |
michael@0 | 267 | expectedLoads = 1; |
michael@0 | 268 | expectedDialogs = 2; |
michael@0 | 269 | iframe1.src = exampleCom + "authenticate.sjs?"+ |
michael@0 | 270 | "user=user4name&"+ |
michael@0 | 271 | "pass=user4pass&"+ |
michael@0 | 272 | "realm=mochirealm4&"+ |
michael@0 | 273 | "proxy_user=proxy_user3&"+ |
michael@0 | 274 | "proxy_pass=proxy_pass3&"+ |
michael@0 | 275 | "proxy_realm=proxy_realm3"; |
michael@0 | 276 | |
michael@0 | 277 | |
michael@0 | 278 | break; |
michael@0 | 279 | |
michael@0 | 280 | case 5: |
michael@0 | 281 | // Same as the previous two steps but let the server generate |
michael@0 | 282 | // huge content load to check http channel is capable to handle |
michael@0 | 283 | // case when auth dialog is canceled or accepted before unauthenticated |
michael@0 | 284 | // content data is load from the server. (This would be better to |
michael@0 | 285 | // implement using delay of server response). |
michael@0 | 286 | ok(true, "doTest testNum 5"); |
michael@0 | 287 | expectedLoads = 1; |
michael@0 | 288 | expectedDialogs = 1; |
michael@0 | 289 | iframe1.src = exampleCom + "authenticate.sjs?"+ |
michael@0 | 290 | "user=user5name&"+ |
michael@0 | 291 | "pass=user5pass&"+ |
michael@0 | 292 | "realm=mochirealm5&"+ |
michael@0 | 293 | "proxy_user=proxy_user4&"+ |
michael@0 | 294 | "proxy_pass=proxy_pass4&"+ |
michael@0 | 295 | "proxy_realm=proxy_realm4&"+ |
michael@0 | 296 | "huge=1"; |
michael@0 | 297 | break; |
michael@0 | 298 | |
michael@0 | 299 | case 6: |
michael@0 | 300 | // Reload the frame from the previous step and let the proxy |
michael@0 | 301 | // authentication pass but WWW fail. We expect two dialogs |
michael@0 | 302 | // and an unathenticated page content load. |
michael@0 | 303 | ok(true, "doTest testNum 6"); |
michael@0 | 304 | expectedLoads = 1; |
michael@0 | 305 | expectedDialogs = 2; |
michael@0 | 306 | iframe1.src = exampleCom + "authenticate.sjs?"+ |
michael@0 | 307 | "user=user5name&"+ |
michael@0 | 308 | "pass=user5pass&"+ |
michael@0 | 309 | "realm=mochirealm5&"+ |
michael@0 | 310 | "proxy_user=proxy_user4&"+ |
michael@0 | 311 | "proxy_pass=proxy_pass4&"+ |
michael@0 | 312 | "proxy_realm=proxy_realm4&"+ |
michael@0 | 313 | "huge=1"; |
michael@0 | 314 | break; |
michael@0 | 315 | |
michael@0 | 316 | case 7: |
michael@0 | 317 | // Reload again and let pass all authentication dialogs. |
michael@0 | 318 | // Check we get the authenticated content not broken by |
michael@0 | 319 | // the unauthenticated content. |
michael@0 | 320 | ok(true, "doTest testNum 7"); |
michael@0 | 321 | expectedLoads = 1; |
michael@0 | 322 | expectedDialogs = 1; |
michael@0 | 323 | iframe1Doc.location.reload(); |
michael@0 | 324 | break; |
michael@0 | 325 | |
michael@0 | 326 | case 8: |
michael@0 | 327 | // Check we proccess all challenges sent by server when |
michael@0 | 328 | // user cancels prompts |
michael@0 | 329 | ok(true, "doTest testNum 8"); |
michael@0 | 330 | expectedLoads = 1; |
michael@0 | 331 | expectedDialogs = 5; |
michael@0 | 332 | iframe1.src = exampleCom + "authenticate.sjs?"+ |
michael@0 | 333 | "user=user6name&"+ |
michael@0 | 334 | "pass=user6pass&"+ |
michael@0 | 335 | "realm=mochirealm6&"+ |
michael@0 | 336 | "proxy_user=proxy_user5&"+ |
michael@0 | 337 | "proxy_pass=proxy_pass5&"+ |
michael@0 | 338 | "proxy_realm=proxy_realm5&"+ |
michael@0 | 339 | "huge=1&"+ |
michael@0 | 340 | "multiple=3"; |
michael@0 | 341 | break; |
michael@0 | 342 | |
michael@0 | 343 | case 9: |
michael@0 | 344 | finishTest(); |
michael@0 | 345 | return; |
michael@0 | 346 | } |
michael@0 | 347 | |
michael@0 | 348 | startCallbackTimer(); |
michael@0 | 349 | } |
michael@0 | 350 | |
michael@0 | 351 | function handleDialog(doc, testNum) |
michael@0 | 352 | { |
michael@0 | 353 | var dialog = doc.getElementById("commonDialog"); |
michael@0 | 354 | |
michael@0 | 355 | switch (testNum) |
michael@0 | 356 | { |
michael@0 | 357 | case 1: |
michael@0 | 358 | case 2: |
michael@0 | 359 | dialog.acceptDialog(); |
michael@0 | 360 | break; |
michael@0 | 361 | |
michael@0 | 362 | case 3: |
michael@0 | 363 | dialog.cancelDialog(); |
michael@0 | 364 | setTimeout(onFrameLoad, 10); // there are no successful frames for test 3 |
michael@0 | 365 | break; |
michael@0 | 366 | |
michael@0 | 367 | case 4: |
michael@0 | 368 | if (expectedDialogs == 2) |
michael@0 | 369 | dialog.acceptDialog(); |
michael@0 | 370 | else |
michael@0 | 371 | dialog.cancelDialog(); |
michael@0 | 372 | break; |
michael@0 | 373 | |
michael@0 | 374 | case 5: |
michael@0 | 375 | dialog.cancelDialog(); |
michael@0 | 376 | setTimeout(onFrameLoad, 10); // there are no successful frames for test 5 |
michael@0 | 377 | break; |
michael@0 | 378 | |
michael@0 | 379 | case 6: |
michael@0 | 380 | if (expectedDialogs == 2) |
michael@0 | 381 | dialog.acceptDialog(); |
michael@0 | 382 | else |
michael@0 | 383 | dialog.cancelDialog(); |
michael@0 | 384 | break; |
michael@0 | 385 | |
michael@0 | 386 | case 7: |
michael@0 | 387 | dialog.acceptDialog(); |
michael@0 | 388 | break; |
michael@0 | 389 | |
michael@0 | 390 | case 8: |
michael@0 | 391 | if (expectedDialogs == 3 || expectedDialogs == 1) |
michael@0 | 392 | dialog.acceptDialog(); |
michael@0 | 393 | else |
michael@0 | 394 | dialog.cancelDialog(); |
michael@0 | 395 | break; |
michael@0 | 396 | |
michael@0 | 397 | default: |
michael@0 | 398 | ok(false, "Unhandled testNum "+testNum+" in handleDialog"); |
michael@0 | 399 | } |
michael@0 | 400 | |
michael@0 | 401 | if (--expectedDialogs > 0) |
michael@0 | 402 | startCallbackTimer(); |
michael@0 | 403 | } |
michael@0 | 404 | |
michael@0 | 405 | function doCheck(testNum) |
michael@0 | 406 | { |
michael@0 | 407 | var iframe1Doc = SpecialPowers.wrap(iframe1).contentDocument; |
michael@0 | 408 | var iframe2aDoc = SpecialPowers.wrap(iframe2a).contentDocument; |
michael@0 | 409 | var iframe2bDoc = SpecialPowers.wrap(iframe2b).contentDocument; |
michael@0 | 410 | switch (testNum) |
michael@0 | 411 | { |
michael@0 | 412 | case 1: |
michael@0 | 413 | ok(true, "doCheck testNum 1"); |
michael@0 | 414 | is(monitor.windowsRegistered, 3, "Registered 3 open dialogs"); |
michael@0 | 415 | |
michael@0 | 416 | var authok1 = iframe1Doc.getElementById("ok").textContent; |
michael@0 | 417 | var proxyok1 = iframe1Doc.getElementById("proxy").textContent; |
michael@0 | 418 | |
michael@0 | 419 | var authok2a = iframe2aDoc.getElementById("ok").textContent; |
michael@0 | 420 | var proxyok2a = iframe2aDoc.getElementById("proxy").textContent; |
michael@0 | 421 | |
michael@0 | 422 | var authok2b = iframe2bDoc.getElementById("ok").textContent; |
michael@0 | 423 | var proxyok2b = iframe2bDoc.getElementById("proxy").textContent; |
michael@0 | 424 | |
michael@0 | 425 | is(authok1, "PASS", "WWW Authorization OK, frame1"); |
michael@0 | 426 | is(authok2a, "PASS", "WWW Authorization OK, frame2a"); |
michael@0 | 427 | is(authok2b, "PASS", "WWW Authorization OK, frame2b"); |
michael@0 | 428 | is(proxyok1, "PASS", "Proxy Authorization OK, frame1"); |
michael@0 | 429 | is(proxyok2a, "PASS", "Proxy Authorization OK, frame2a"); |
michael@0 | 430 | is(proxyok2b, "PASS", "Proxy Authorization OK, frame2b"); |
michael@0 | 431 | break; |
michael@0 | 432 | |
michael@0 | 433 | case 2: |
michael@0 | 434 | is(monitor.windowsRegistered, 2, "Registered 2 open dialogs"); |
michael@0 | 435 | ok(true, "doCheck testNum 2"); |
michael@0 | 436 | |
michael@0 | 437 | function checkIframe(frame) { |
michael@0 | 438 | var doc = SpecialPowers.wrap(frame).contentDocument; |
michael@0 | 439 | |
michael@0 | 440 | var authok = doc.getElementById("ok").textContent; |
michael@0 | 441 | var proxyok = doc.getElementById("proxy").textContent; |
michael@0 | 442 | |
michael@0 | 443 | is(authok, "PASS", "WWW Authorization OK, " + frame.id); |
michael@0 | 444 | is(proxyok, "PASS", "Proxy Authorization OK, " + frame.id); |
michael@0 | 445 | } |
michael@0 | 446 | |
michael@0 | 447 | checkIframe(iframe1Doc.getElementById("iframe1")); |
michael@0 | 448 | checkIframe(iframe1Doc.getElementById("iframe2")); |
michael@0 | 449 | checkIframe(iframe1Doc.getElementById("iframe3")); |
michael@0 | 450 | break; |
michael@0 | 451 | |
michael@0 | 452 | case 3: |
michael@0 | 453 | ok(true, "doCheck testNum 3"); |
michael@0 | 454 | is(monitor.windowsRegistered, 1, "Registered 1 open dialog"); |
michael@0 | 455 | |
michael@0 | 456 | // ensure that the page content is not displayed on failed proxy auth |
michael@0 | 457 | is(iframe1Doc.getElementById("ok"), undefined, "frame did not load"); |
michael@0 | 458 | break; |
michael@0 | 459 | |
michael@0 | 460 | case 4: |
michael@0 | 461 | ok(true, "doCheck testNum 4"); |
michael@0 | 462 | is(monitor.windowsRegistered, 2, "Registered 2 open dialogs"); |
michael@0 | 463 | var authok1 = iframe1Doc.getElementById("ok").textContent; |
michael@0 | 464 | var proxyok1 = iframe1Doc.getElementById("proxy").textContent; |
michael@0 | 465 | |
michael@0 | 466 | is(authok1, "FAIL", "WWW Authorization FAILED, frame1"); |
michael@0 | 467 | is(proxyok1, "PASS", "Proxy Authorization OK, frame1"); |
michael@0 | 468 | break; |
michael@0 | 469 | |
michael@0 | 470 | case 5: |
michael@0 | 471 | ok(true, "doCheck testNum 5"); |
michael@0 | 472 | is(monitor.windowsRegistered, 1, "Registered 1 open dialog"); |
michael@0 | 473 | |
michael@0 | 474 | // ensure that the page content is not displayed on failed proxy auth |
michael@0 | 475 | is(iframe1Doc.getElementById("footnote"), undefined, "frame did not load"); |
michael@0 | 476 | break; |
michael@0 | 477 | |
michael@0 | 478 | case 6: |
michael@0 | 479 | ok(true, "doCheck testNum 6"); |
michael@0 | 480 | is(monitor.windowsRegistered, 2, "Registered 2 open dialogs"); |
michael@0 | 481 | var authok1 = iframe1Doc.getElementById("ok").textContent; |
michael@0 | 482 | var proxyok1 = iframe1Doc.getElementById("proxy").textContent; |
michael@0 | 483 | var footnote = iframe1Doc.getElementById("footnote").textContent; |
michael@0 | 484 | |
michael@0 | 485 | is(authok1, "FAIL", "WWW Authorization FAILED, frame1"); |
michael@0 | 486 | is(proxyok1, "PASS", "Proxy Authorization OK, frame1"); |
michael@0 | 487 | is(footnote, "This is a footnote after the huge content fill", |
michael@0 | 488 | "Footnote present and loaded completely"); |
michael@0 | 489 | break; |
michael@0 | 490 | |
michael@0 | 491 | case 7: |
michael@0 | 492 | ok(true, "doCheck testNum 7"); |
michael@0 | 493 | is(monitor.windowsRegistered, 1, "Registered 1 open dialogs"); |
michael@0 | 494 | var authok1 = iframe1Doc.getElementById("ok").textContent; |
michael@0 | 495 | var proxyok1 = iframe1Doc.getElementById("proxy").textContent; |
michael@0 | 496 | var footnote = iframe1Doc.getElementById("footnote").textContent; |
michael@0 | 497 | |
michael@0 | 498 | is(authok1, "PASS", "WWW Authorization OK, frame1"); |
michael@0 | 499 | is(proxyok1, "PASS", "Proxy Authorization OK, frame1"); |
michael@0 | 500 | is(footnote, "This is a footnote after the huge content fill", |
michael@0 | 501 | "Footnote present and loaded completely"); |
michael@0 | 502 | break; |
michael@0 | 503 | |
michael@0 | 504 | case 8: |
michael@0 | 505 | ok(true, "doCheck testNum 8"); |
michael@0 | 506 | is(monitor.windowsRegistered, 5, "Registered 5 open dialogs"); |
michael@0 | 507 | var authok1 = iframe1Doc.getElementById("ok").textContent; |
michael@0 | 508 | var proxyok1 = iframe1Doc.getElementById("proxy").textContent; |
michael@0 | 509 | var footnote = iframe1Doc.getElementById("footnote").textContent; |
michael@0 | 510 | |
michael@0 | 511 | is(authok1, "PASS", "WWW Authorization OK, frame1"); |
michael@0 | 512 | is(proxyok1, "PASS", "Proxy Authorization OK, frame1"); |
michael@0 | 513 | is(footnote, "This is a footnote after the huge content fill", |
michael@0 | 514 | "Footnote present and loaded completely"); |
michael@0 | 515 | break; |
michael@0 | 516 | |
michael@0 | 517 | default: |
michael@0 | 518 | ok(false, "Unhandled testNum "+testNum+" in doCheck"); |
michael@0 | 519 | } |
michael@0 | 520 | } |
michael@0 | 521 | |
michael@0 | 522 | </script> |
michael@0 | 523 | </head> |
michael@0 | 524 | <body> |
michael@0 | 525 | <iframe id="iframe1"></iframe> |
michael@0 | 526 | <iframe id="iframe2a"></iframe> |
michael@0 | 527 | <iframe id="iframe2b"></iframe> |
michael@0 | 528 | </body> |
michael@0 | 529 | </html> |