commit 3da33fc90ce348fbc594d5aa45e85d8a4f08e539 Author: Jonathan Hao jhao@mozilla.com Date: Tue Dec 13 11:44:59 2016 +0800
Bug 1274020 - Tests that shows the Cache Web API is separated by origin attributes. r=baku
--HG-- extra : rebase_source : 8964090126795ed45650e76c4f9e02b2e60f62cf --- .../originattributes/test/browser/browser.ini | 1 + .../originattributes/test/browser/browser_cacheAPI.js | 18 ++++++++++++++++++ .../components/originattributes/test/browser/head.js | 7 +++++-- 3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/browser/components/originattributes/test/browser/browser.ini b/browser/components/originattributes/test/browser/browser.ini index 121dd0c..911d42f 100644 --- a/browser/components/originattributes/test/browser/browser.ini +++ b/browser/components/originattributes/test/browser/browser.ini @@ -68,3 +68,4 @@ support-files = [browser_sharedworker.js] [browser_httpauth.js] [browser_clientAuth.js] +[browser_cacheAPI.js] diff --git a/browser/components/originattributes/test/browser/browser_cacheAPI.js b/browser/components/originattributes/test/browser/browser_cacheAPI.js new file mode 100644 index 0000000..87dcfe5 --- /dev/null +++ b/browser/components/originattributes/test/browser/browser_cacheAPI.js @@ -0,0 +1,18 @@ +const requestURL = "https://test1.example.com"; + +function getResult(aBrowser) { + return ContentTask.spawn(aBrowser, requestURL, function* (url) { + let cache = yield content.caches.open("TEST_CACHE"); + let response = yield cache.match(url); + if (response) { + return response.statusText; + } + let result = Math.random().toString(); + response = new content.Response("", { statusText: result }); + yield cache.put(url, response); + return result; + }); +} + +IsolationTestTools.runTests("https://test2.example.com", getResult, null, null, + false, /* aUseHttps */ true); diff --git a/browser/components/originattributes/test/browser/head.js b/browser/components/originattributes/test/browser/head.js index 96559a1..7835ccf 100644 --- a/browser/components/originattributes/test/browser/head.js +++ b/browser/components/originattributes/test/browser/head.js @@ -279,7 +279,7 @@ this.IsolationTestTools = { * An optional boolean to ensure we get results before the next tab is opened. */ runTests(aURL, aGetResultFuncs, aCompareResultFunc, aBeforeFunc, - aGetResultImmediately) { + aGetResultImmediately, aUseHttps) { let pageURL; let firstFrameSetting; let secondFrameSetting; @@ -301,7 +301,10 @@ this.IsolationTestTools = { aGetResultFuncs = [aGetResultFuncs]; }
- let tabSettings = [ + let tabSettings = aUseHttps ? [ + { firstPartyDomain: "https://example.com", userContextId: 1}, + { firstPartyDomain: "https://example.org", userContextId: 2} + ] : [ { firstPartyDomain: "http://example.com", userContextId: 1}, { firstPartyDomain: "http://example.org", userContextId: 2} ];
tbb-commits@lists.torproject.org