| OLD | NEW | 
|    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         policyHits.pop(); |  290         policyHits.pop(); | 
|  291     } |  291     } | 
|  292     policyHits.push([wnd, node, item]); |  292     policyHits.push([wnd, node, item]); | 
|  293   } |  293   } | 
|  294  |  294  | 
|  295   function runTest([name, body, expectedURL, expectedType, expectedThirdParty, e
     xplicitEvent], stage) |  295   function runTest([name, body, expectedURL, expectedType, expectedThirdParty, e
     xplicitEvent], stage) | 
|  296   { |  296   { | 
|  297     defaultMatcher.clear(); |  297     defaultMatcher.clear(); | 
|  298  |  298  | 
|  299     if (stage > 1) |  299     if (stage > 1) | 
|  300       defaultMatcher.add(Filter.fromText(expectedURL)); |  300       if (stage == 7) | 
 |  301         defaultMatcher.add(Filter.fromText(expectedURL + "$domain=127.0.0.1")); | 
 |  302       else | 
 |  303         defaultMatcher.add(Filter.fromText(expectedURL)); | 
 |  304  | 
|  301     if (stage == 3) |  305     if (stage == 3) | 
|  302       defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$document")); |  306       defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$document")); | 
|  303     if (stage == 4) |  307     if (stage == 4) | 
|  304       defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$~document")); |  308       defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$~document")); | 
|  305     if (stage == 5) |  309     if (stage == 5) | 
|  306       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)); | 
 |  311     if (stage == 6 || stage == 7) | 
 |  312       defaultMatcher.add(Filter.fromText("@@||127.0.0.1:1234/test|$genericblock"
     )); | 
|  307  |  313  | 
|  308     if (!explicitEvent) |  314     if (!explicitEvent) | 
|  309     { |  315     { | 
|  310       if (body.indexOf("2000/svg") >= 0) |  316       if (body.indexOf("2000/svg") >= 0) | 
|  311       { |  317       { | 
|  312         // SVG image: add an onload attribute to the document element |  318         // SVG image: add an onload attribute to the document element | 
|  313         body = body.replace(/(<svg\b)/, '$1 onload="this.dispatchEvent(new Custo
     mEvent(\'abp:frameready\', {bubbles: true}));"'); |  319         body = body.replace(/(<svg\b)/, '$1 onload="this.dispatchEvent(new Custo
     mEvent(\'abp:frameready\', {bubbles: true}));"'); | 
|  314       } |  320       } | 
|  315       else |  321       else | 
|  316       { |  322       { | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  354  |  360  | 
|  355       // Work around weird Firefox behavior, where worker scripts succesfully lo
     ad with empty 404 pages. |  361       // Work around weird Firefox behavior, where worker scripts succesfully lo
     ad with empty 404 pages. | 
|  356       var error = "<b>Not found...<b>"; |  362       var error = "<b>Not found...<b>"; | 
|  357       response.bodyOutputStream.write(error, error.length); |  363       response.bodyOutputStream.write(error, error.length); | 
|  358     }); |  364     }); | 
|  359  |  365  | 
|  360     policyHits = []; |  366     policyHits = []; | 
|  361     var callback = function() |  367     var callback = function() | 
|  362     { |  368     { | 
|  363       let expectedStatus = "allowed"; |  369       let expectedStatus = "allowed"; | 
|  364       if (stage == 3) |  370       if (stage == 3 || stage == 6) | 
|  365         equal(policyHits.length, 0, "Number of policy hits"); |  371         equal(policyHits.length, 0, "Number of policy hits"); | 
|  366       // We cannot rely on the correctness of policy hits for sitekey filters du
     e to blocking |  372       // We cannot rely on the correctness of policy hits for sitekey filters du
     e to blocking | 
|  367       // filter hits being counted even if the resource doesn't end up getting b
     locked |  373       // filter hits being counted even if the resource doesn't end up getting b
     locked | 
|  368       else if (stage != 5) |  374       else if (stage != 5) | 
|  369       { |  375       { | 
|  370         equal(policyHits.length, 1, "Number of policy hits"); |  376         equal(policyHits.length, 1, "Number of policy hits"); | 
|  371         if (policyHits.length == 1) |  377         if (policyHits.length == 1) | 
|  372         { |  378         { | 
|  373           let [wnd, node, item] = policyHits[0]; |  379           let [wnd, node, item] = policyHits[0]; | 
|  374  |  380  | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|  392     }; |  398     }; | 
|  393     frame.addEventListener("abp:frameready", callback, false, true); |  399     frame.addEventListener("abp:frameready", callback, false, true); | 
|  394     frame.setAttribute("src", "http://127.0.0.1:1234/test"); |  400     frame.setAttribute("src", "http://127.0.0.1:1234/test"); | 
|  395   } |  401   } | 
|  396  |  402  | 
|  397   let stageDescriptions = { |  403   let stageDescriptions = { | 
|  398     1: "running without filters", |  404     1: "running without filters", | 
|  399     2: "running with filter %S", |  405     2: "running with filter %S", | 
|  400     3: "running with filter %S and site exception", |  406     3: "running with filter %S and site exception", | 
|  401     4: "running with filter %S and exception not applicable to sites", |  407     4: "running with filter %S and exception not applicable to sites", | 
|  402     5: "running with filter %S and sitekey exception" |  408     5: "running with filter %S and sitekey exception", | 
 |  409     6: "running with filter %S and $genericblock exception", | 
 |  410     7: "running with filter %S$domain=127.0.0.1 and $genericblock exception" | 
|  403   }; |  411   }; | 
|  404  |  412  | 
|  405   for (let test = 0; test < tests.length; test++) |  413   for (let test = 0; test < tests.length; test++) | 
|  406   { |  414   { | 
|  407     let [name, body, expectedURL, expectedType, expectedDomain, expectedThirdPar
     ty] = tests[test]; |  415     let [name, body, expectedURL, expectedType, expectedDomain, expectedThirdPar
     ty] = tests[test]; | 
|  408     for (let stage = 1; stage in stageDescriptions; stage++) |  416     for (let stage = 1; stage in stageDescriptions; stage++) | 
|  409     { |  417     { | 
|  410       let stageDescription = stageDescriptions[stage]; |  418       let stageDescription = stageDescriptions[stage]; | 
|  411       if (stageDescription.indexOf("%S") >= 0) |  419       if (stageDescription.indexOf("%S") >= 0) | 
|  412         stageDescription = stageDescription.replace("%S", expectedURL); |  420         stageDescription = stageDescription.replace("%S", expectedURL); | 
|  413  |  421  | 
|  414       asyncTest(name + " (" + stageDescription + ")", runTest.bind(null, tests[t
     est], stage)); |  422       asyncTest(name + " (" + stageDescription + ")", runTest.bind(null, tests[t
     est], stage)); | 
|  415     } |  423     } | 
|  416   } |  424   } | 
|  417 })(); |  425 })(); | 
| OLD | NEW |