From d2d11ce8bd3b42ab8d528548d3ece2a545b14f7c Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 28 Jun 2016 13:02:03 -0700 Subject: [PATCH] Invoke callback instead of returning --- lib/renderer/extensions/storage.js | 15 +++++++++------ spec/api-browser-window-spec.js | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/renderer/extensions/storage.js b/lib/renderer/extensions/storage.js index b0941d98c8ce..af3978e64846 100644 --- a/lib/renderer/extensions/storage.js +++ b/lib/renderer/extensions/storage.js @@ -12,11 +12,17 @@ const setStorage = (storageType, storage) => { window.localStorage.setItem(`__chrome.storage.${storageType}__`, json) } +const scheduleCallback = (items, callback) => { + setTimeout(function () { + callback(items) + }) +} + const getStorageManager = (storageType) => { return { get (keys, callback) { const storage = getStorage(storageType) - if (keys == null) return storage + if (keys == null) return scheduleCallback(storage, callback) let defaults = {} switch (typeof keys) { @@ -30,7 +36,7 @@ const getStorageManager = (storageType) => { } break } - if (keys.length === 0) return {} + if (keys.length === 0) return scheduleCallback({}, callback) let items = {} keys.forEach(function (key) { @@ -38,10 +44,7 @@ const getStorageManager = (storageType) => { if (value == null) value = defaults[key] items[key] = value }) - - setTimeout(function () { - callback(items) - }) + scheduleCallback(items, callback) }, set (items, callback) { diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index b7b647e1c4ee..ea82d59f2960 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -1025,7 +1025,7 @@ describe('browser-window module', function () { }, /Unexpected token }/) }) - describe.only('when the devtools is docked', function () { + describe('when the devtools is docked', function () { it('creates the extension', function (done) { w.webContents.openDevTools({mode: 'bottom'})