Bug 1054572 - Reload iframe in test_classifier.html to test cache API calls in nsChannelClassifier.cpp r=gcp
☠☠ backed out by 603a6713b031 ☠ ☠
authorSteve Workman <sworkman@mozilla.com>
Fri, 22 Aug 2014 10:49:29 -0700
changeset 201250 cbd1a7c4d0b006fd0bf2104c88af35d30bfccf47
parent 201249 466d677dacc05daa52b020fb76ed3c434df65fee
child 201251 73a965cfceba7dec44228a30dc264b7c23ef0fa9
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersgcp
bugs1054572
milestone34.0a1
Bug 1054572 - Reload iframe in test_classifier.html to test cache API calls in nsChannelClassifier.cpp r=gcp
toolkit/components/url-classifier/tests/mochitest/classifierFrame.html
toolkit/components/url-classifier/tests/mochitest/test_classifier.html
--- a/toolkit/components/url-classifier/tests/mochitest/classifierFrame.html
+++ b/toolkit/components/url-classifier/tests/mochitest/classifierFrame.html
@@ -10,16 +10,25 @@ function checkLoads() {
   // Make sure the javascript did not load.
   window.parent.is(scriptItem, "untouched", "Should not load bad javascript");
 
   // Make sure the css did not load.
   var elt = document.getElementById("styleCheck");
   var style = document.defaultView.getComputedStyle(elt, "");
   window.parent.isnot(style.visibility, "hidden", "Should not load bad css");
 
+  // Call parent.loadTestFrame again to test classification metadata in HTTP
+  // cache entries.
+  if (window.parent.firstLoad) {
+    window.parent.info("Reloading from cache...");
+    window.parent.firstLoad = false;
+    window.parent.loadTestFrame();
+    return;
+  }
+
   // End (parent) test.
   window.parent.SimpleTest.finish();
 }
 
 </script>
 
 <!-- Try loading from a malware javascript URI -->
 <script type="text/javascript" src="http://malware.example.com/tests/toolkit/components/url-classifier/tests/mochitest/evil.js"></script>
--- a/toolkit/components/url-classifier/tests/mochitest/test_classifier.html
+++ b/toolkit/components/url-classifier/tests/mochitest/test_classifier.html
@@ -10,27 +10,32 @@
 <div id="content" style="display: none">
 </div>
 <pre id="test">
 
 <script class="testbody" type="text/javascript">
 
 var Cc = SpecialPowers.Cc;
 var Ci = SpecialPowers.Ci;
+var firstLoad = true;
 
 // Add some URLs to the malware database.
 var testData = "malware.example.com/";
 var testUpdate =
   "n:1000\ni:test-malware-simple\nad:1\n" +
   "a:524:32:" + testData.length + "\n" +
   testData;
 
 var dbService = Cc["@mozilla.org/url-classifier/dbservice;1"]
                 .getService(Ci.nsIUrlClassifierDBService);
 
+function loadTestFrame() {
+  document.getElementById("testFrame").src = "classifierFrame.html";
+}
+
 function doUpdate(update) {
   var listener = {
     QueryInterface: function(iid)
     {
       if (iid.equals(Ci.nsISupports) ||
           iid.equals(Ci.nsIUrlClassifierUpdateObserver))
         return this;
 
@@ -41,20 +46,17 @@ function doUpdate(update) {
     updateError: function(errorCode) {
       ok(false, "Couldn't update classifier.");
       // Abort test.
       SimpleTest.finish();
     },
     updateSuccess: function(requestedTimeout) {
       SpecialPowers.pushPrefEnv(
         {"set" : [["browser.safebrowsing.malware.enabled", true]]},
-        function loadTestFrame() {
-          document.getElementById("testFrame").src = "classifierFrame.html";
-        }
-      );
+        loadTestFrame);
     }
   };
 
   dbService.beginUpdate(listener, "test-malware-simple", "");
   dbService.beginStream("", "");
   dbService.updateStream(update);
   dbService.finishStream();
   dbService.finishUpdate();