merge m-c to fx-team
authorTim Taubert <tim.taubert@gmx.de>
Mon, 14 May 2012 23:35:24 +0200
changeset 98394 0c78207fc93fc690b4b8c6d3a5f6a9e064913298
parent 98389 3ab55d40ecd4059e5a3a638eac85844806923729 (current diff)
parent 98393 92317d7fe1ee65695f5af9e60cfba27226d68e15 (diff)
child 98465 6e921e933c2b90410e55ad265b229e8a24f1b6ce
child 98587 6aa19c67af2f1fe3878cb200953e5a64541f4eca
push id173
push userlsblakk@mozilla.com
push dateFri, 24 Aug 2012 15:39:16 +0000
treeherdermozilla-release@bcc45eb1fb41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone15.0a1
first release with
nightly linux32
0c78207fc93f / 15.0a1 / 20120515030518 / files
nightly linux64
0c78207fc93f / 15.0a1 / 20120515030518 / files
nightly mac
0c78207fc93f / 15.0a1 / 20120515030518 / files
nightly win32
0c78207fc93f / 15.0a1 / 20120515030518 / files
nightly win64
0c78207fc93f / 15.0a1 / 20120515030518 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
merge m-c to fx-team
browser/components/tabview/test/browser_tabview_storage_policy.js
deleted file mode 100644
--- a/browser/components/tabview/test/browser_tabview_storage_policy.js
+++ /dev/null
@@ -1,181 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-const PREF_DISK_CACHE_SSL = "browser.cache.disk_cache_ssl";
-
-let pb = Cc["@mozilla.org/privatebrowsing;1"].
-         getService(Ci.nsIPrivateBrowsingService);
-
-let contentWindow;
-let newTab;
-
-function test() {
-  waitForExplicitFinish();
-
-  newTab = gBrowser.addTab();
-
-  HttpRequestObserver.register();
-
-  registerCleanupFunction(function () {
-    HttpRequestObserver.unregister();
-    if (gBrowser.tabs[1])
-      gBrowser.removeTab(gBrowser.tabs[1]);
-    hideTabView();
-
-    Services.prefs.clearUserPref(PREF_DISK_CACHE_SSL);
-    pb.privateBrowsingEnabled = false;
-  });
-
-  showTabView(function() {
-    contentWindow = TabView.getContentWindow();
-    test1();
-  });
-}
-
-
-function test1() {
-  // page with cache-control: no-store, should not save thumbnail
-  HttpRequestObserver.cacheControlValue = "no-store";
-
-  whenStorageDenied(newTab, function () {
-    let tabItem = newTab._tabViewTabItem;
-
-    ok(!contentWindow.StoragePolicy.canStoreThumbnailForTab(newTab), 
-       "Should not save the thumbnail for tab");
-
-    whenDeniedToSaveImageData(tabItem, test2);
-    tabItem.saveThumbnail({synchronously: true});
-    HttpRequestObserver.cacheControlValue = null;
-  });
-
-  newTab.linkedBrowser.loadURI("http://www.example.com/browser/browser/components/tabview/test/dummy_page.html");
-}
-
-function test2() {
-  // page with cache-control: private, should save thumbnail
-  HttpRequestObserver.cacheControlValue = "private";
-
-  newTab.linkedBrowser.loadURI("http://www.example.com/");
-  afterAllTabsLoaded(function() {
-    let tabItem = newTab._tabViewTabItem;
-
-    ok(contentWindow.StoragePolicy.canStoreThumbnailForTab(newTab), 
-       "Should save the thumbnail for tab");
-
-    whenSavedCachedImageData(tabItem, test3);
-    tabItem.saveThumbnail({synchronously: true});
-  });
-}
-
-function test3() {
-  // page with cache-control: private with https caching enabled, should save thumbnail
-  HttpRequestObserver.cacheControlValue = "private";
-
-  Services.prefs.setBoolPref(PREF_DISK_CACHE_SSL, true);
-
-  newTab.linkedBrowser.loadURI("https://example.com/browser/browser/components/tabview/test/dummy_page.html");
-  afterAllTabsLoaded(function() {
-    let tabItem = newTab._tabViewTabItem;
-
-    ok(contentWindow.StoragePolicy.canStoreThumbnailForTab(newTab),
-       "Should save the thumbnail for tab");
-
-    whenSavedCachedImageData(tabItem, test4);
-    tabItem.saveThumbnail({synchronously: true});
-  });
-}
-
-function test4() {
-  // page with cache-control: public with https caching disabled, should save thumbnail
-  HttpRequestObserver.cacheControlValue = "public";
-
-  Services.prefs.setBoolPref(PREF_DISK_CACHE_SSL, false);
-
-  newTab.linkedBrowser.loadURI("https://example.com/browser/browser/components/tabview/test/");
-  afterAllTabsLoaded(function() {
-    let tabItem = newTab._tabViewTabItem;
-
-    ok(contentWindow.StoragePolicy.canStoreThumbnailForTab(newTab),
-       "Should save the thumbnail for tab");
-
-    whenSavedCachedImageData(tabItem, test5);
-    tabItem.saveThumbnail({synchronously: true});
-  });
-}
-
-function test5() {
-  // page with cache-control: private with https caching disabled, should not save thumbnail
-  HttpRequestObserver.cacheControlValue = "private";
-
-  whenStorageDenied(newTab, function () {
-    let tabItem = newTab._tabViewTabItem;
-
-    ok(!contentWindow.StoragePolicy.canStoreThumbnailForTab(newTab),
-       "Should not save the thumbnail for tab");
-
-    whenDeniedToSaveImageData(tabItem, function () {
-      gBrowser.removeTab(newTab);
-      test6();
-    });
-
-    tabItem.saveThumbnail({synchronously: true});
-  });
-
-  newTab.linkedBrowser.loadURI("https://example.com/");
-}
-
-// ensure that no thumbnails are saved while in private browsing mode
-function test6() {
-  HttpRequestObserver.cacheControlValue = "public";
-
-  togglePrivateBrowsing(function () {
-    let tab = gBrowser.tabs[0];
-
-    ok(!contentWindow.StoragePolicy.canStoreThumbnailForTab(tab),
-       "Should not save the thumbnail for tab");
-
-    togglePrivateBrowsing(finish);
-  });
-}
-
-let HttpRequestObserver = {
-  cacheControlValue: null,
-
-  observe: function(subject, topic, data) {
-    if (topic == "http-on-examine-response" && this.cacheControlValue) {
-      let httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
-      httpChannel.setResponseHeader("Cache-Control", this.cacheControlValue, false);
-    }
-  },
-
-  register: function() {
-    Services.obs.addObserver(this, "http-on-examine-response", false);
-  },
-
-  unregister: function() {
-    Services.obs.removeObserver(this, "http-on-examine-response");
-  }
-};
-
-function whenSavedCachedImageData(tabItem, callback) {
-  tabItem.addSubscriber("savedCachedImageData", function onSaved() {
-    tabItem.removeSubscriber("savedCachedImageData", onSaved);
-    callback();
-  });
-}
-
-function whenDeniedToSaveImageData(tabItem, callback) {
-  tabItem.addSubscriber("deniedToSaveImageData", function onDenied() {
-    tabItem.removeSubscriber("deniedToSaveImageData", onDenied);
-    callback();
-  });
-}
-
-function whenStorageDenied(tab, callback) {
-  let mm = tab.linkedBrowser.messageManager;
-
-  mm.addMessageListener("Panorama:StoragePolicy:denied", function onDenied() {
-    mm.removeMessageListener("Panorama:StoragePolicy:denied", onDenied);
-    executeSoon(callback);
-  });
-}
--- a/browser/components/thumbnails/PageThumbs.jsm
+++ b/browser/components/thumbnails/PageThumbs.jsm
@@ -240,24 +240,26 @@ let PageThumbs = {
     }
     catch (e) {
       return true;
     }
   },
 };
 
 let PageThumbsStorage = {
-  getFileForURL: function Storage_getFileForURL(aURL) {
+  getFileForURL: function Storage_getFileForURL(aURL, aOptions) {
     let hash = this._calculateMD5Hash(aURL);
-    let parts = [THUMBNAIL_DIRECTORY, hash[0], hash[1], hash.slice(2) + ".png"];
-    return FileUtils.getFile("ProfD", parts);
+    let parts = [THUMBNAIL_DIRECTORY, hash[0], hash[1]];
+    let file = FileUtils.getDir("ProfD", parts, aOptions && aOptions.createPath);
+    file.append(hash.slice(2) + ".png");
+    return file;
   },
 
   write: function Storage_write(aURL, aDataStream, aCallback) {
-    let file = this.getFileForURL(aURL);
+    let file = this.getFileForURL(aURL, {createPath: true});
     let fos = FileUtils.openSafeFileOutputStream(file);
 
     NetUtil.asyncCopy(aDataStream, fos, function (aResult) {
       FileUtils.closeSafeFileOutputStream(fos);
       aCallback(Components.isSuccessCode(aResult));
     });
   },
 
--- a/browser/components/thumbnails/test/Makefile.in
+++ b/browser/components/thumbnails/test/Makefile.in
@@ -11,15 +11,16 @@ relativesrcdir  = browser/components/thu
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _BROWSER_FILES = \
 	browser_thumbnails_capture.js \
 	browser_thumbnails_redirect.js \
 	browser_thumbnails_storage.js \
 	browser_thumbnails_bug726727.js \
+	browser_thumbnails_bug753755.js \
 	head.js \
 	background_red.html \
 	background_red_redirect.sjs \
 	$(NULL)
 
 libs::	$(_BROWSER_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/browser/components/thumbnails/test/browser_thumbnails_bug753755.js
@@ -0,0 +1,15 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Make sure that PageThumbsStorage.getFileForURL(url) doesn't implicitly
+ * create the file's parent path.
+ */
+function runTests() {
+  let url = "http://non.existant.url/";
+  let file = PageThumbsStorage.getFileForURL(url);
+  ok(!file.exists() && !file.parent.exists(), "file and path don't exist");
+
+  let file = PageThumbsStorage.getFileForURL(url, {createPath: true});
+  ok(!file.exists() && file.parent.exists(), "path exists, file doesn't");
+}
--- a/browser/components/thumbnails/test/browser_thumbnails_storage.js
+++ b/browser/components/thumbnails/test/browser_thumbnails_storage.js
@@ -13,17 +13,17 @@ XPCOMUtils.defineLazyGetter(this, "Sanit
 });
 
 /**
  * These tests ensure that the thumbnail storage is working as intended.
  * Newly captured thumbnails should be saved as files and they should as well
  * be removed when the user sanitizes their history.
  */
 function runTests() {
-  clearHistory();
+  yield clearHistory();
 
   // create a thumbnail
   yield addTab(URL);
   yield whenFileExists();
   gBrowser.removeTab(gBrowser.selectedTab);
 
   // clear all browser history
   yield clearHistory();
@@ -67,17 +67,17 @@ function clearHistory(aUseRange) {
     s.range = [usec - 10 * 60 * 1000 * 1000, usec];
   }
 
   s.sanitize();
   s.range = null;
 
   executeSoon(function () {
     if (PageThumbsStorage.getFileForURL(URL).exists())
-      clearHistory(aFile, aUseRange);
+      clearHistory(aUseRange);
     else
       next();
   });
 }
 
 function whenFileExists() {
   let callback = whenFileExists;
 
--- a/browser/components/thumbnails/test/head.js
+++ b/browser/components/thumbnails/test/head.js
@@ -24,19 +24,22 @@ function test() {
  * The test runner that controls the execution flow of our tests.
  */
 let TestRunner = {
   /**
    * Starts the test runner.
    */
   run: function () {
     waitForExplicitFinish();
+    this._iter = runTests();
 
-    this._iter = runTests();
-    this.next();
+    if (this._iter)
+      this.next();
+    else
+      finish();
   },
 
   /**
    * Runs the next available test or finishes if there's no test left.
    */
   next: function () {
     try {
       TestRunner._iter.next();
--- a/build/automationutils.py
+++ b/build/automationutils.py
@@ -474,17 +474,17 @@ class ShutdownLeakLogger(object):
       self._logWindow(line)
     elif line[2:10] == "DOCSHELL":
       self._logDocShell(line)
     elif line.startswith("TEST-START"):
       fileName = line.split(" ")[-1].strip().replace("chrome://mochitests/content/browser/", "")
       self.currentTest = {"fileName": fileName, "windows": set(), "docShells": set()}
     elif line.startswith("INFO TEST-END"):
       # don't track a test if no windows or docShells leaked
-      if self.currentTest["windows"] or self.currentTest["docShells"]:
+      if self.currentTest and (self.currentTest["windows"] or self.currentTest["docShells"]):
         self.tests.append(self.currentTest)
       self.currentTest = None
     elif line.startswith("INFO TEST-START | Shutdown"):
       self.seenShutdown = True
 
   def parse(self):
     leakingTests = self._parseLeakingTests()