Bug 1271249 - Fixed by Bug1269361 adding new OriginAttributes. r=baku
authorJames Andreou <jandreou@mozilla.com>
Tue, 07 Jun 2016 08:27:41 +0200
changeset 300845 52c23e12438cfc1909cca15eafec9c103c909819
parent 300844 4f1b49de286936fa27c74249e2ed1fcdd9c542d9
child 300846 ae5286493f1570628d17c1d81a73a782291dd613
push id19599
push usercbook@mozilla.com
push dateWed, 08 Jun 2016 10:16:21 +0000
treeherderfx-team@81f4cc3f6f4c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1271249, 1269361
milestone50.0a1
Bug 1271249 - Fixed by Bug1269361 adding new OriginAttributes. r=baku
browser/components/privatebrowsing/test/browser/browser.ini
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_blobUrl.js
browser/components/privatebrowsing/test/browser/empty_file.html
--- a/browser/components/privatebrowsing/test/browser/browser.ini
+++ b/browser/components/privatebrowsing/test/browser/browser.ini
@@ -9,16 +9,17 @@ support-files =
   browser_privatebrowsing_localStorage_page1.html
   browser_privatebrowsing_localStorage_page2.html
   browser_privatebrowsing_placesTitleNoUpdate.html
   browser_privatebrowsing_protocolhandler_page.html
   browser_privatebrowsing_windowtitle_page.html
   head.js
   popup.html
   title.sjs
+  empty_file.html
 
 [browser_privatebrowsing_DownloadLastDirWithCPS.js]
 [browser_privatebrowsing_about.js]
 tags = trackingprotection
 [browser_privatebrowsing_aboutHomeButtonAfterWindowClose.js]
 [browser_privatebrowsing_aboutSessionRestore.js]
 [browser_privatebrowsing_cache.js]
 [browser_privatebrowsing_certexceptionsui.js]
@@ -41,8 +42,9 @@ tags = trackingprotection
 [browser_privatebrowsing_sidebar.js]
 [browser_privatebrowsing_theming.js]
 [browser_privatebrowsing_ui.js]
 [browser_privatebrowsing_urlbarfocus.js]
 [browser_privatebrowsing_windowtitle.js]
 [browser_privatebrowsing_zoom.js]
 [browser_privatebrowsing_zoomrestore.js]
 [browser_privatebrowsing_newtab_from_popup.js]
+[browser_privatebrowsing_blobUrl.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_blobUrl.js
@@ -0,0 +1,48 @@
+"use strict";
+
+// Here we want to test that blob URLs are not available between private and
+// non-private browsing.
+
+const BASE_URI = "http://mochi.test:8888/browser/browser/components/"
+  + "privatebrowsing/test/browser/empty_file.html";
+
+add_task(function* test() {
+  info("Creating a normal window...");
+  let win = yield BrowserTestUtils.openNewBrowserWindow();
+  let tab = win.gBrowser.selectedBrowser;
+  tab.loadURI(BASE_URI);
+  yield BrowserTestUtils.browserLoaded(tab);
+
+  let blobURL;
+
+  info("Creating a blob URL...");
+  yield ContentTask.spawn(tab, null, function() {
+    return Promise.resolve(content.window.URL.createObjectURL(new content.window.Blob([123])));
+  }).then(newURL => { blobURL = newURL });
+
+  info("Blob URL: " + blobURL);
+
+  info("Creating a private window...");
+  let privateWin = yield BrowserTestUtils.openNewBrowserWindow({ private: true });
+  let privateTab = privateWin.gBrowser.selectedBrowser;
+  privateTab.loadURI(BASE_URI);
+  yield BrowserTestUtils.browserLoaded(privateTab);
+
+  yield ContentTask.spawn(privateTab, blobURL, function(url) {
+    return new Promise(resolve => {
+      var xhr = new content.window.XMLHttpRequest();
+      xhr.open("GET", url);
+      try {
+        xhr.send();
+        resolve("OpenSucceeded");
+      } catch(e) {
+        resolve("OpenThrew");
+      }
+    });
+  }).then(status => {
+    is(status, "OpenThrew", "Using a blob URI from one user context id in another should not work");
+  });
+
+  yield BrowserTestUtils.closeWindow(win);
+  yield BrowserTestUtils.closeWindow(privateWin);
+});
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/browser/components/privatebrowsing/test/browser/empty_file.html
@@ -0,0 +1,1 @@
+<html><body></body></html>
\ No newline at end of file