| LEFT | RIGHT |
| 1 (function() | 1 (function() |
| 2 { | 2 { |
| 3 let server = null; | 3 let server = null; |
| 4 let frame = null; | 4 let frame = null; |
| 5 let requestNotifier = null; | 5 let requestNotifier = null; |
| 6 let httpProtocol = null; | 6 let httpProtocol = null; |
| 7 | 7 |
| 8 module("Content policy", { | 8 module("Content policy", { |
| 9 setup: function() | 9 setup: function() |
| 10 { | 10 { |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 if (prevWnd == wnd && prevItem.location == item.location && prevItem.type
== item.type && prevItem.docDomain == item.docDomain) | 290 if (prevWnd == wnd && prevItem.location == item.location && prevItem.type
== item.type && prevItem.docDomain == item.docDomain) |
| 291 policyHits.pop(); | 291 policyHits.pop(); |
| 292 } | 292 } |
| 293 policyHits.push([wnd, node, item]); | 293 policyHits.push([wnd, node, item]); |
| 294 } | 294 } |
| 295 | 295 |
| 296 function runTest([name, body, expectedURL, expectedType, expectedThirdParty, e
xplicitEvent], stage) | 296 function runTest([name, body, expectedURL, expectedType, expectedThirdParty, e
xplicitEvent], stage) |
| 297 { | 297 { |
| 298 defaultMatcher.clear(); | 298 defaultMatcher.clear(); |
| 299 | 299 |
| 300 if (stage > 1) | 300 if (stage == 7) |
| 301 if (stage == 7) | 301 defaultMatcher.add(Filter.fromText(expectedURL + "$domain=127.0.0.1")); |
| 302 defaultMatcher.add(Filter.fromText(expectedURL + "$domain=127.0.0.1")); | 302 else if (stage > 1) |
| 303 else | 303 defaultMatcher.add(Filter.fromText(expectedURL)); |
| 304 defaultMatcher.add(Filter.fromText(expectedURL)); | |
| 305 | 304 |
| 306 if (stage == 3) | 305 if (stage == 3) |
| 307 defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$document")); | 306 defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$document")); |
| 308 if (stage == 4) | 307 if (stage == 4) |
| 309 defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$~document")); | 308 defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$~document")); |
| 310 if (stage == 5) | 309 if (stage == 5) |
| 311 defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$document,site
key=" + publickey)); | 310 defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$document,site
key=" + publickey)); |
| 312 if (stage == 6 || stage == 7) | 311 if (stage == 6 || stage == 7) |
| 313 defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$genericblock"
)); | 312 defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$genericblock"
)); |
| 314 if (stage == 8) | 313 if (stage == 8) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 363 |
| 365 // Work around weird Firefox behavior, where worker scripts succesfully lo
ad with empty 404 pages. | 364 // Work around weird Firefox behavior, where worker scripts succesfully lo
ad with empty 404 pages. |
| 366 var error = "<b>Not found...<b>"; | 365 var error = "<b>Not found...<b>"; |
| 367 response.bodyOutputStream.write(error, error.length); | 366 response.bodyOutputStream.write(error, error.length); |
| 368 }); | 367 }); |
| 369 | 368 |
| 370 policyHits = []; | 369 policyHits = []; |
| 371 var callback = function() | 370 var callback = function() |
| 372 { | 371 { |
| 373 let expectedStatus = "allowed"; | 372 let expectedStatus = "allowed"; |
| 374 if (stage == 3 || stage == 6) | 373 if (stage == 3) |
| 375 equal(policyHits.length, 0, "Number of policy hits"); | 374 equal(policyHits.length, 0, "Number of policy hits"); |
| 376 // We cannot rely on the correctness of policy hits for sitekey filters du
e to blocking | 375 // We cannot rely on the correctness of policy hits for sitekey filters du
e to blocking |
| 377 // filter hits being counted even if the resource doesn't end up getting b
locked | 376 // filter hits being counted even if the resource doesn't end up getting b
locked |
| 378 else if (stage != 5 && stage != 8) | 377 else if (stage != 5 && stage != 6 && stage != 8) |
| 379 { | 378 { |
| 380 equal(policyHits.length, 1, "Number of policy hits"); | 379 equal(policyHits.length, 1, "Number of policy hits"); |
| 381 if (policyHits.length == 1) | 380 if (policyHits.length == 1) |
| 382 { | 381 { |
| 383 let [wnd, node, item] = policyHits[0]; | 382 let [wnd, node, item] = policyHits[0]; |
| 384 | 383 |
| 385 equal(item.location, expectedURL, "Request URL"); | 384 equal(item.location, expectedURL, "Request URL"); |
| 386 | 385 |
| 387 expectedStatus = (stage == 1 ? "allowed" : "blocked"); | 386 expectedStatus = (stage == 1 ? "allowed" : "blocked"); |
| 388 let actualStatus = (item.filter ? "blocked" : "allowed"); | 387 let actualStatus = (item.filter ? "blocked" : "allowed"); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 for (let stage = 1; stage in stageDescriptions; stage++) | 420 for (let stage = 1; stage in stageDescriptions; stage++) |
| 422 { | 421 { |
| 423 let stageDescription = stageDescriptions[stage]; | 422 let stageDescription = stageDescriptions[stage]; |
| 424 if (stageDescription.indexOf("%S") >= 0) | 423 if (stageDescription.indexOf("%S") >= 0) |
| 425 stageDescription = stageDescription.replace("%S", expectedURL); | 424 stageDescription = stageDescription.replace("%S", expectedURL); |
| 426 | 425 |
| 427 asyncTest(name + " (" + stageDescription + ")", runTest.bind(null, tests[t
est], stage)); | 426 asyncTest(name + " (" + stageDescription + ")", runTest.bind(null, tests[t
est], stage)); |
| 428 } | 427 } |
| 429 } | 428 } |
| 430 })(); | 429 })(); |
| LEFT | RIGHT |