Bug 1143833 - Add tests for the ignoreSearch match mode in DOM cache; r=bkelly
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 16 Mar 2015 16:13:13 -0400
changeset 233855 ff73dd4e2d62cfc0b816043afc2812831b627e0e
parent 233854 da2630091edcc7db1743cf7d6571c0cd4c1ca191
child 233856 1bec876948eaa4b87e36136747dde98597403904
push id56981
push usereakhgari@mozilla.com
push dateMon, 16 Mar 2015 21:13:27 +0000
treeherdermozilla-inbound@ff73dd4e2d62 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1143833
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1143833 - Add tests for the ignoreSearch match mode in DOM cache; r=bkelly
dom/cache/test/mochitest/test_cache_matchAll_request.js
dom/cache/test/mochitest/test_cache_match_request.js
--- a/dom/cache/test/mochitest/test_cache_matchAll_request.js
+++ b/dom/cache/test/mochitest/test_cache_matchAll_request.js
@@ -1,11 +1,12 @@
 var request1 = new Request("//mochi.test:8888/?1&" + context + "#fragment");
 var request2 = new Request("//mochi.test:8888/?2&" + context);
 var request3 = new Request("//mochi.test:8888/?3&" + context);
+var requestWithAltQS = new Request("//mochi.test:8888/?queryString");
 var unknownRequest = new Request("//mochi.test:8888/non/existing/path?" + context);
 var response1, response3;
 var c;
 var response1Text, response3Text;
 var name = "matchAll-request" + context;
 
 function checkResponse(r, response, responseText) {
   ok(r !== response, "The objects should not be the same");
@@ -28,27 +29,29 @@ fetch(new Request(request1)).then(functi
   response1Text = text;
   return fetch(new Request(request3));
 }).then(function(r) {
   response3 = r;
   return response3.text();
 }).then(function(text) {
   response3Text = text;
   return testRequest(request1, request2, request3, unknownRequest,
+                     requestWithAltQS,
                      request1.url.replace("#fragment", "#other"));
 }).then(function() {
   return testRequest(request1.url, request2.url, request3.url,
-                     unknownRequest.url,
+                     unknownRequest.url, requestWithAltQS.url,
                      request1.url.replace("#fragment", "#other"));
 }).then(function() {
   testDone();
 });
 
 // The request arguments can either be a URL string, or a Request object.
 function testRequest(request1, request2, request3, unknownRequest,
+                     requestWithAlternateQueryString,
                      requestWithDifferentFragment) {
   return caches.open(name).then(function(cache) {
     c = cache;
     return c.add(request1);
   }).then(function() {
     return c.add(request3);
   }).then(function() {
     return Promise.all(
@@ -69,16 +72,25 @@ function testRequest(request1, request2,
     is(r.length, 1, "Should only find 1 item");
     return checkResponse(r[0], response1, response1Text);
   }).then(function() {
     return c.matchAll(requestWithDifferentFragment);
   }).then(function(r) {
     is(r.length, 1, "Should only find 1 item");
     return checkResponse(r[0], response1, response1Text);
   }).then(function() {
+    return c.matchAll(requestWithAlternateQueryString,
+                      {ignoreSearch: true, cacheName: name});
+  }).then(function(r) {
+    is(r.length, 2, "Should find 2 items");
+    return Promise.all([
+      checkResponse(r[0], response1, response1Text),
+      checkResponse(r[1], response3, response3Text)
+    ]);
+  }).then(function() {
     return c.matchAll(request3);
   }).then(function(r) {
     is(r.length, 1, "Should only find 1 item");
     return checkResponse(r[0], response3, response3Text);
   }).then(function() {
     return c.matchAll();
   }).then(function(r) {
     is(r.length, 2, "Should find 2 items");
--- a/dom/cache/test/mochitest/test_cache_match_request.js
+++ b/dom/cache/test/mochitest/test_cache_match_request.js
@@ -1,9 +1,10 @@
 var request = new Request("//mochi.test:8888/?" + context + "#fragment");
+var requestWithAltQS = new Request("//mochi.test:8888/?queryString");
 var unknownRequest = new Request("//mochi.test:8888/non/existing/path?" + context);
 var response;
 var c;
 var responseText;
 var name = "match-request" + context;
 
 function checkResponse(r) {
   ok(r !== response, "The objects should not be the same");
@@ -19,27 +20,28 @@ function checkResponse(r) {
   });
 }
 
 fetch(new Request(request)).then(function(r) {
   response = r;
   return response.text();
 }).then(function(text) {
   responseText = text;
-  return testRequest(request, unknownRequest,
+  return testRequest(request, unknownRequest, requestWithAltQS,
                      request.url.replace("#fragment", "#other"));
 }).then(function() {
-  return testRequest(request.url, unknownRequest.url,
+  return testRequest(request.url, unknownRequest.url, requestWithAltQS.url,
                      request.url.replace("#fragment", "#other"));
 }).then(function() {
   testDone();
 });
 
 // The request argument can either be a URL string, or a Request object.
-function testRequest(request, unknownRequest, requestWithDifferentFragment) {
+function testRequest(request, unknownRequest, requestWithAlternateQueryString,
+                     requestWithDifferentFragment) {
   return caches.open(name).then(function(cache) {
     c = cache;
     return c.add(request);
   }).then(function() {
     return Promise.all(
       ["HEAD", "POST", "PUT", "DELETE", "OPTIONS"]
         .map(function(method) {
           var r = new Request(request, {method: method});
@@ -59,16 +61,21 @@ function testRequest(request, unknownReq
     return caches.match(request);
   }).then(function(r) {
     return checkResponse(r);
   }).then(function() {
     return caches.match(requestWithDifferentFragment);
   }).then(function(r) {
     return checkResponse(r);
   }).then(function() {
+    return caches.match(requestWithAlternateQueryString,
+                        {ignoreSearch: true, cacheName: name});
+  }).then(function(r) {
+    return checkResponse(r);
+  }).then(function() {
     return caches.match(request, {cacheName: name});
   }).then(function(r) {
     return checkResponse(r);
   }).then(function() {
     return caches.match(request, {cacheName: name + "mambojambo"})
       .then(function() {
         ok(false, "Promise should be rejected");
       }, function(err) {