Bug 477666: namespaces broken after an appcache update. r=honzab, sr=bz
authorDave Camp <dcamp@mozilla.com>
Mon, 09 Feb 2009 22:40:40 -0800
changeset 24811 78038be8f0f24324327143b7227f494d2d87c8a2
parent 24810 87f99c57b51fb542048263ff9ff4adc9aa14e0dd
child 24812 541fc9b1a7444a520bbf4513d2f95bc2164a71d8
push idunknown
push userunknown
push dateunknown
reviewershonzab, bz
bugs477666
milestone1.9.2a1pre
Bug 477666: namespaces broken after an appcache update. r=honzab, sr=bz
dom/tests/mochitest/ajax/offline/changingManifest.cacheManifest
dom/tests/mochitest/ajax/offline/test_changingManifest.html
netwerk/cache/src/nsDiskCacheDeviceSQL.cpp
--- a/dom/tests/mochitest/ajax/offline/changingManifest.cacheManifest
+++ b/dom/tests/mochitest/ajax/offline/changingManifest.cacheManifest
@@ -1,5 +1,6 @@
 CACHE MANIFEST
 # v1 - this will be replaced by test scripts.
 changing1Hour.sjs
 changing1Sec.sjs
-
+NETWORK:
+onwhitelist.html
--- a/dom/tests/mochitest/ajax/offline/test_changingManifest.html
+++ b/dom/tests/mochitest/ajax/offline/test_changingManifest.html
@@ -28,16 +28,28 @@ function finish()
   OfflineTest.finish();
 }
 
 function manifestUpdatedAgain()
 {
   OfflineTest.ok(gGotChecking, "Should get a checking event on the second update");
   OfflineTest.ok(gGotDownloading, "Should get a downloading event on the second update");
 
+  // The second manifest has no NETWORK entry, but we are still
+  // associated with the first version of the manifest, so we should
+  // be able to access the whitelisted entry.
+  try {
+    var xhr = new XMLHttpRequest();
+    xhr.open("GET", "onwhitelist.html", false);
+    xhr.send();
+    OfflineTest.ok(true, "Fetched from the initial cache's whitelist.");
+  } catch (e) {
+    OfflineTest.ok(false, "Failed to fetch from the initial cache's whitelist.");
+  }
+
   // Get the initial contents of the first two files.
   fetcher = new OfflineCacheContents([g1SecUrl, g1HourUrl]);
   fetcher.fetch(function(contents) {
     // Make sure the contents of the 1-second-expiration file have changed,
     // but that the 1-hour-expiration has not.
     OfflineTest.isnot(gCacheContents[g1SecUrl], contents[g1SecUrl], "1-second expiration should have changed");
     OfflineTest.is(gCacheContents[g1HourUrl], contents[g1HourUrl], "1-hour expiration should not have changed");
 
--- a/netwerk/cache/src/nsDiskCacheDeviceSQL.cpp
+++ b/netwerk/cache/src/nsDiskCacheDeviceSQL.cpp
@@ -1099,22 +1099,20 @@ nsOfflineCacheDevice::Init()
 
     // Search for namespaces that match the URI.  Use the <= operator
     // to ensure that we use the index on moz_cache_namespaces.
     StatementSql ( mStatement_FindClientByNamespace, "SELECT ns.ClientID, ns.ItemType FROM"
                                                      "  moz_cache_namespaces AS ns JOIN moz_cache_groups AS groups"
                                                      "  ON ns.ClientID = groups.ActiveClientID"
                                                      " WHERE ns.NameSpace <= ?1 AND ?1 GLOB ns.NameSpace || '*'"
                                                      " ORDER BY ns.NameSpace DESC, groups.ActivateTimeStamp DESC;"),
-    StatementSql ( mStatement_FindNamespaceEntry,    "SELECT ns.NameSpace, ns.Data, ns.ItemType FROM "
-                                                     "  moz_cache_namespaces AS ns JOIN moz_cache_groups AS groups"
-                                                     "  ON ns.ClientID = groups.ActiveClientID"
+    StatementSql ( mStatement_FindNamespaceEntry,    "SELECT NameSpace, Data, ItemType FROM moz_cache_namespaces"
                                                      " WHERE ClientID = ?1"
                                                      " AND NameSpace <= ?2 AND ?2 GLOB NameSpace || '*'"
-                                                     " ORDER BY ns.NameSpace DESC, groups.ActivateTimeStamp DESC;"),
+                                                     " ORDER BY NameSpace DESC;"),
     StatementSql ( mStatement_InsertNamespaceEntry,  "INSERT INTO moz_cache_namespaces (ClientID, NameSpace, Data, ItemType) VALUES(?, ?, ?, ?);"),
   };
   for (PRUint32 i = 0; NS_SUCCEEDED(rv) && i < NS_ARRAY_LENGTH(prepared); ++i)
   {
     LOG(("Creating statement: %s\n", prepared[i].sql));
 
     rv = mDB->CreateStatement(nsDependentCString(prepared[i].sql),
                               getter_AddRefs(prepared[i].statement));