Bug 1230563 - Part 2: Test for corrected cookie permission behavior, r=ehsan, a=sylvestre
authorMichael Layzell <michael@thelayzells.com>
Wed, 09 Dec 2015 15:47:53 -0500
changeset 310929 0991cdfecaee9b0a1655c16715b7371f721aa3e0
parent 310928 3f9c48e199bf9f90e09c5ea0fcc1a9c605f26366
child 310930 40e5fc1082d3cb307091398c375382f65fe86d35
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, sylvestre
bugs1230563
milestone45.0a2
Bug 1230563 - Part 2: Test for corrected cookie permission behavior, r=ehsan, a=sylvestre
dom/tests/mochitest/localstorage/frameLocalStorageSessionOnly.html
dom/tests/mochitest/localstorage/mochitest.ini
dom/tests/mochitest/localstorage/test_localStorageSessionPrefOverride.html
dom/webidl/Storage.webidl
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/localstorage/frameLocalStorageSessionOnly.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<html>
+  <body>
+    <script>
+      parent.postMessage(SpecialPowers.wrap(localStorage).isSessionOnly, "*");
+    </script>
+  </body>
+</html>
--- a/dom/tests/mochitest/localstorage/mochitest.ini
+++ b/dom/tests/mochitest/localstorage/mochitest.ini
@@ -11,16 +11,17 @@ support-files =
   frameQuotaSessionOnly.html
   frameReplace.html
   frameSlaveEqual.html
   frameSlaveNotEqual.html
   interOriginFrame.js
   interOriginTest.js
   interOriginTest2.js
   localStorageCommon.js
+  frameLocalStorageSessionOnly.html
 
 [test_appIsolation.html]
 skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #bug 793211 # b2g(needs https to work) b2g-debug(needs https to work) b2g-desktop(needs https to work)
 [test_brokenUTF-16.html]
 [test_bug600307-DBOps.html]
 [test_bug746272-1.html]
 [test_bug746272-2.html]
 skip-if = os == "android" || toolkit == 'gonk' # bug 962029
@@ -51,8 +52,9 @@ skip-if = buildapp == 'b2g' || toolkit =
 [test_localStorageQuotaSessionOnly.html]
 skip-if = buildapp == 'b2g' || toolkit == 'android' #TIMED_OUT # b2g(needs https support)
 [test_localStorageQuotaSessionOnly2.html]
 skip-if = buildapp == 'b2g' || toolkit == 'android' #TIMED_OUT # b2g(needs https support)
 [test_localStorageReplace.html]
 skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug)) || toolkit == 'android'
 [test_lowDeviceStorage.html]
 [test_storageConstructor.html]
+[test_localStorageSessionPrefOverride.html]
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/localstorage/test_localStorageSessionPrefOverride.html
@@ -0,0 +1,54 @@
+<html>
+  <head>
+    <title>Local Storage Session Pref Override</title>
+    <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+    <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
+    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+    <script>
+      const ACCEPT_SESSION = 2;
+
+      add_task(function*() {
+        yield new Promise((resolve, reject) => {
+          SpecialPowers.pushPrefEnv({"set": [["network.cookie.lifetimePolicy",
+                                              ACCEPT_SESSION]]},
+                                    resolve);
+        });
+
+        // Before setting permission
+        yield new Promise((resolve) => {
+          var frame = document.createElement('iframe');
+          frame.src = "frameLocalStorageSessionOnly.html";
+
+          var listener = (e) => {
+            is(e.data, true, "Before adding permission should be session only");
+            window.removeEventListener('message', listener);
+            resolve();
+          };
+          window.addEventListener('message', listener);
+          document.body.appendChild(frame);
+        });
+
+        // After setting permission
+        yield new Promise((resolve) => {
+          SpecialPowers.pushPermissions([{"type": "cookie", "allow": 1, "context": document}],
+                                        resolve);
+        });
+
+        yield new Promise((resolve) => {
+          var frame = document.createElement('iframe');
+          frame.src = "frameLocalStorageSessionOnly.html";
+
+          var listener = (e) => {
+            is(e.data, false, "After adding permission should not be session only");
+            window.removeEventListener('message', listener);
+            resolve();
+          };
+          window.addEventListener('message', listener);
+          document.body.appendChild(frame);
+        });
+      });
+    </script>
+  </head>
+  <body>
+  </body>
+</html>
--- a/dom/webidl/Storage.webidl
+++ b/dom/webidl/Storage.webidl
@@ -24,9 +24,12 @@ interface Storage {
   [Throws]
   setter creator void setItem(DOMString key, DOMString value);
 
   [Throws]
   deleter void removeItem(DOMString key);
 
   [Throws]
   void clear();
+
+  [ChromeOnly]
+  readonly attribute boolean isSessionOnly;
 };