Bug 1384741 - Part 2: Allow file_report_chromescript.js to listen for more than one CSP violation report. r=bz a=lizzard
authorCameron McCormack <cam@mcc.id.au>
Mon, 07 Aug 2017 10:11:04 +0800
changeset 421143 ce4bac7cc01ee52323fbd9b118a338622cfc068c
parent 421142 2ca70aa40eae0268d6abf65175aa93a7c14fa7a1
child 421144 083d55339a1dff04531da5aca017191bac5f42a3
push id7609
push usercmccormack@mozilla.com
push dateMon, 14 Aug 2017 09:19:34 +0000
treeherdermozilla-beta@87ae6494d5b1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, lizzard
bugs1384741
milestone56.0
Bug 1384741 - Part 2: Allow file_report_chromescript.js to listen for more than one CSP violation report. r=bz a=lizzard MozReview-Commit-ID: 8ym5OqSUTMW
dom/security/test/csp/file_report_chromescript.js
dom/security/test/csp/test_blocked_uri_in_reports.html
dom/security/test/csp/test_report.html
--- a/dom/security/test/csp/file_report_chromescript.js
+++ b/dom/security/test/csp/file_report_chromescript.js
@@ -41,14 +41,16 @@ var openingObserver = {
           uploadStream.QueryInterface(Ci.nsISeekableStream).seek(Ci.nsISeekableStream.NS_SEEK_SET, 0);
         }
         message.report = reportText;
       } catch (e) {
         message.error = e.toString();
       }
 
       sendAsyncMessage('opening-request-completed', message);
-      Services.obs.removeObserver(openingObserver, 'http-on-opening-request');
     }
   }
 };
 
 Services.obs.addObserver(openingObserver, 'http-on-opening-request');
+addMessageListener("finish", function() {
+  Services.obs.removeObserver(openingObserver, 'http-on-opening-request');
+});
--- a/dom/security/test/csp/test_blocked_uri_in_reports.html
+++ b/dom/security/test/csp/test_blocked_uri_in_reports.html
@@ -52,16 +52,17 @@ script.addMessageListener('opening-reque
       // http://test1.example.com/tests/dom/security/test/csp/file_path_matching.js
       is(cspReport["blocked-uri"], "http://test1.example.com", "Incorrect blocked-uri");
     } catch (e) {
       ok(false, "Could not query report (exception: " + e + ")");
     }
   }
 
   script.removeMessageListener('opening-request-completed', ml);
+  script.sendAsyncMessage("finish");
   SimpleTest.finish();
 });
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   var src = "file_testserver.sjs";
   // append the file that should be served
--- a/dom/security/test/csp/test_report.html
+++ b/dom/security/test/csp/test_report.html
@@ -79,16 +79,17 @@ script.addMessageListener('opening-reque
       // test for the proper values in the report object
       window.checkResults(reportObj);
     } catch (e) {
       ok(false, "Could not query report (exception: " + e + ")");
     }
   }
 
   script.removeMessageListener('opening-request-completed', ml);
+  script.sendAsyncMessage("finish");
   SimpleTest.finish();
 });
 
 SimpleTest.waitForExplicitFinish();
 
 // load the resource which will generate a CSP violation report
 // save this for last so that our listeners are registered.
 var src = "file_testserver.sjs";