--- a/devtools/client/storage/test/browser_storage_dynamic_updates_cookies.js
+++ b/devtools/client/storage/test/browser_storage_dynamic_updates_cookies.js
@@ -47,17 +47,17 @@ add_task(function* () {
[
getCookieId("c1", "test1.example.org", "/browser"),
getCookieId("c2", "test1.example.org", "/browser")
]
],
]);
checkCell(c1id, "value", "1.2.3.4.5.6.7");
- gWindow.addCookie("c1", '{"foo": 4,"bar":6}', "/browser");
+ yield addCookie("c1", '{"foo": 4,"bar":6}', "/browser");
yield gUI.once("store-objects-edit");
yield findVariableViewProperties(finalValue[0], false);
yield findVariableViewProperties(finalValue[1], true);
yield checkState([
[
["cookies", "http://test1.example.org"],
@@ -65,17 +65,17 @@ add_task(function* () {
getCookieId("c1", "test1.example.org", "/browser"),
getCookieId("c2", "test1.example.org", "/browser")
]
],
]);
checkCell(c1id, "value", '{"foo": 4,"bar":6}');
// Add a new entry
- gWindow.addCookie("c3", "booyeah");
+ yield addCookie("c3", "booyeah");
yield gUI.once("store-objects-edit");
yield checkState([
[
["cookies", "http://test1.example.org"],
[
getCookieId("c1", "test1.example.org", "/browser"),
@@ -85,17 +85,17 @@ add_task(function* () {
]
],
]);
let c3id = getCookieId("c3", "test1.example.org",
"/browser/devtools/client/storage/test/");
checkCell(c3id, "value", "booyeah");
// Add another
- gWindow.addCookie("c4", "booyeah");
+ yield addCookie("c4", "booyeah");
yield gUI.once("store-objects-edit");
yield checkState([
[
["cookies", "http://test1.example.org"],
[
getCookieId("c1", "test1.example.org", "/browser"),
@@ -107,17 +107,17 @@ add_task(function* () {
]
],
]);
let c4id = getCookieId("c4", "test1.example.org",
"/browser/devtools/client/storage/test/");
checkCell(c4id, "value", "booyeah");
// Removing cookies
- gWindow.removeCookie("c1", "/browser");
+ yield removeCookie("c1", "/browser");
yield gUI.once("store-objects-edit");
yield checkState([
[
["cookies", "http://test1.example.org"],
[
getCookieId("c2", "test1.example.org", "/browser"),
@@ -130,17 +130,17 @@ add_task(function* () {
]);
ok(!gUI.sidebar.hidden, "Sidebar still visible for next row");
// Check if next element's value is visible in sidebar
yield findVariableViewProperties([{name: "c2", value: "foobar"}]);
// Keep deleting till no rows
- gWindow.removeCookie("c3");
+ yield removeCookie("c3");
yield gUI.once("store-objects-edit");
yield checkState([
[
["cookies", "http://test1.example.org"],
[
getCookieId("c2", "test1.example.org", "/browser"),
@@ -148,37 +148,53 @@ add_task(function* () {
"/browser/devtools/client/storage/test/")
]
],
]);
// Check if next element's value is visible in sidebar
yield findVariableViewProperties([{name: "c2", value: "foobar"}]);
- gWindow.removeCookie("c2", "/browser");
+ yield removeCookie("c2", "/browser");
yield gUI.once("store-objects-edit");
yield checkState([
[
["cookies", "http://test1.example.org"],
[
getCookieId("c4", "test1.example.org",
"/browser/devtools/client/storage/test/")
]
],
]);
// Check if next element's value is visible in sidebar
yield findVariableViewProperties([{name: "c4", value: "booyeah"}]);
- gWindow.removeCookie("c4");
+ yield removeCookie("c4");
yield gUI.once("store-objects-edit");
yield checkState([
[["cookies", "http://test1.example.org"], [ ]],
]);
ok(gUI.sidebar.hidden, "Sidebar is hidden when no rows");
yield finishTests();
});
+
+function* addCookie(name, value, path) {
+ yield ContentTask.spawn(gBrowser.selectedBrowser, [name, value, path],
+ ([nam, valu, pat]) => {
+ content.wrappedJSObject.addCookie(nam, valu, pat);
+ }
+ );
+}
+
+function* removeCookie(name, path) {
+ yield ContentTask.spawn(gBrowser.selectedBrowser, [name, path],
+ ([nam, pat]) => {
+ content.wrappedJSObject.removeCookie(nam, pat);
+ }
+ );
+}
--- a/devtools/client/storage/test/browser_storage_dynamic_updates_localStorage.js
+++ b/devtools/client/storage/test/browser_storage_dynamic_updates_localStorage.js
@@ -15,39 +15,39 @@ add_task(function* () {
yield checkState([
[
["localStorage", "http://test1.example.org"],
["ls1", "ls2", "ls3", "ls4", "ls5", "ls6", "ls7"]
],
]);
- gWindow.localStorage.removeItem("ls4");
+ yield removeLocalStorageItem("ls4");
yield gUI.once("store-objects-edit");
yield checkState([
[
["localStorage", "http://test1.example.org"],
["ls1", "ls2", "ls3", "ls5", "ls6", "ls7"]
],
]);
- gWindow.localStorage.setItem("ls4", "again");
+ yield setLocalStorageItem("ls4", "again");
yield gUI.once("store-objects-edit");
yield checkState([
[
["localStorage", "http://test1.example.org"],
["ls1", "ls2", "ls3", "ls4", "ls5", "ls6", "ls7"]
],
]);
// Updating a row
- gWindow.localStorage.setItem("ls2", "ls2-changed");
+ yield setLocalStorageItem("ls2", "ls2-changed");
yield gUI.once("store-objects-edit");
checkCell("ls2", "value", "ls2-changed");
// Clearing items.
yield ContentTask.spawn(gBrowser.selectedBrowser, null, function () {
content.wrappedJSObject.clear();
@@ -59,8 +59,24 @@ add_task(function* () {
[
["localStorage", "http://test1.example.org"],
[ ]
],
]);
yield finishTests();
});
+
+function* setLocalStorageItem(key, value) {
+ yield ContentTask.spawn(gBrowser.selectedBrowser, [key, value],
+ ([innerKey, innerValue]) => {
+ content.wrappedJSObject.localStorage.setItem(innerKey, innerValue);
+ }
+ );
+}
+
+function* removeLocalStorageItem(key) {
+ yield ContentTask.spawn(gBrowser.selectedBrowser, key,
+ innerKey => {
+ content.wrappedJSObject.localStorage.removeItem(innerKey);
+ }
+ );
+}
--- a/devtools/client/storage/test/browser_storage_dynamic_updates_sessionStorage.js
+++ b/devtools/client/storage/test/browser_storage_dynamic_updates_sessionStorage.js
@@ -15,34 +15,34 @@ add_task(function* () {
yield checkState([
[
["sessionStorage", "http://test1.example.org"],
["ss1", "ss2", "ss3"]
],
]);
- gWindow.sessionStorage.setItem("ss4", "new-item");
+ yield setSessionStorageItem("ss4", "new-item");
yield gUI.once("store-objects-edit");
yield checkState([
[
["sessionStorage", "http://test1.example.org"],
["ss1", "ss2", "ss3", "ss4"]
],
]);
// deleting item
- gWindow.sessionStorage.removeItem("ss3");
+ yield removeSessionStorageItem("ss3");
yield gUI.once("store-objects-edit");
- gWindow.sessionStorage.removeItem("ss1");
+ yield removeSessionStorageItem("ss1");
yield gUI.once("store-objects-edit");
yield checkState([
[
["sessionStorage", "http://test1.example.org"],
["ss2", "ss4"]
],
@@ -50,17 +50,17 @@ add_task(function* () {
yield selectTableItem("ss2");
ok(!gUI.sidebar.hidden, "sidebar is visible");
// Checking for correct value in sidebar before update
yield findVariableViewProperties([{name: "ss2", value: "foobar"}]);
- gWindow.sessionStorage.setItem("ss2", "changed=ss2");
+ yield setSessionStorageItem("ss2", "changed=ss2");
yield gUI.once("sidebar-updated");
checkCell("ss2", "value", "changed=ss2");
yield findVariableViewProperties([{name: "ss2", value: "changed=ss2"}]);
// Clearing items.
@@ -74,8 +74,24 @@ add_task(function* () {
[
["sessionStorage", "http://test1.example.org"],
[ ]
],
]);
yield finishTests();
});
+
+function* setSessionStorageItem(key, value) {
+ yield ContentTask.spawn(gBrowser.selectedBrowser, [key, value],
+ ([innerKey, innerValue]) => {
+ content.wrappedJSObject.sessionStorage.setItem(innerKey, innerValue);
+ }
+ );
+}
+
+function* removeSessionStorageItem(key) {
+ yield ContentTask.spawn(gBrowser.selectedBrowser, key,
+ innerKey => {
+ content.wrappedJSObject.sessionStorage.removeItem(innerKey);
+ }
+ );
+}
--- a/devtools/client/storage/test/head.js
+++ b/devtools/client/storage/test/head.js
@@ -25,25 +25,25 @@ const MAIN_DOMAIN_WITH_PORT = "http://te
const ALT_DOMAIN = "http://sectest1.example.org/" + PATH;
const ALT_DOMAIN_SECURED = "https://sectest1.example.org:443/" + PATH;
// GUID to be used as a separator in compound keys. This must match the same
// constant in devtools/server/actors/storage.js,
// devtools/client/storage/ui.js and devtools/server/tests/browser/head.js
const SEPARATOR_GUID = "{9d414cc5-8319-0a04-0586-c0a6ae01670a}";
-var gToolbox, gPanelWindow, gWindow, gUI;
+var gToolbox, gPanelWindow, gUI;
// Services.prefs.setBoolPref(DUMPEMIT_PREF, true);
// Services.prefs.setBoolPref(DEBUGGERLOG_PREF, true);
Services.prefs.setBoolPref(STORAGE_PREF, true);
Services.prefs.setBoolPref(CACHES_ON_HTTP_PREF, true);
registerCleanupFunction(() => {
- gToolbox = gPanelWindow = gWindow = gUI = null;
+ gToolbox = gPanelWindow = gUI = null;
Services.prefs.clearUserPref(CACHES_ON_HTTP_PREF);
Services.prefs.clearUserPref(DEBUGGERLOG_PREF);
Services.prefs.clearUserPref(DOM_CACHE);
Services.prefs.clearUserPref(DUMPEMIT_PREF);
Services.prefs.clearUserPref(STORAGE_PREF);
});
/**
@@ -52,19 +52,16 @@ registerCleanupFunction(() => {
*
* @param url {String} The url to be opened in the new tab
* @param options {Object} The tab options for the new tab
*
* @return {Promise} A promise that resolves after the tab is ready
*/
function* openTab(url, options = {}) {
let tab = yield addTab(url, options);
- let content = tab.linkedBrowser.contentWindowAsCPOW;
-
- gWindow = content.wrappedJSObject;
// Setup the async storages in main window and for all its iframes
yield ContentTask.spawn(gBrowser.selectedBrowser, null, function* () {
/**
* Get all windows including frames recursively.
*
* @param {Window} [baseWindow]
* The base window at which to start looking for child windows
@@ -214,18 +211,16 @@ function forceCollections() {
Cu.forceCC();
Cu.forceShrinkingGC();
}
/**
* Cleans up and finishes the test
*/
function* finishTests() {
- // Bug 1233497 makes it so that we can no longer yield CPOWs from Tasks.
- // We work around this by calling clear() via a ContentTask instead.
while (gBrowser.tabs.length > 1) {
yield ContentTask.spawn(gBrowser.selectedBrowser, null, function* () {
/**
* Get all windows including frames recursively.
*
* @param {Window} [baseWindow]
* The base window at which to start looking for child windows
* (optional).