message: recover from invalid localstorage data
diff: @@ -21,16 +21,7 @@ let panelId = undefined;
  function openPage() {
  const getContentWindowInfo = browser.windows.getLastFocused();
  - browser.storage.local.get().then(storage => {
  - const size = Object.assign({
  - height: 960,
  - width: 610
  - }, storage.size);
  -
  - const getSideexWindowInfo = browser.windows.create(Object.assign({
  - url: browser.extension.getURL("assets/index.html"),
  - type: "popup"
  - }, size));
  + const getSideexWindowInfo = openWindowFromStorageResolution();
  Promise.all([getContentWindowInfo, getSideexWindowInfo])
  .then(function(windowInfo) {
  @@ -73,7 +64,6 @@ function openPage() {
  .catch(function(e) {
  console.error(e);
  });
  - });
  browser.contextMenus.create({
  id: "verifyText",
  @@ -111,7 +101,37 @@ function openPage() {
  documentUrlPatterns: ["<all_urls>"],
  contexts: ["all"]
  });
  +}
  +
  +function openWindowFromStorageResolution() {
  + let size = {
  + height: 960,
  + width: 610
  + };
  + return browser.storage.local.get().then(storage => {
  + if (sizeIsValid(storage.size)) {
  + size.height = storage.size.height;
  + size.width = storage.size.width;
  + }
  + return browser.windows.create(Object.assign({
  + url: browser.extension.getURL("assets/index.html"),
  + type: "popup"
  + }, size));
  + }).catch(e => {
  + console.error(e);
  + return browser.windows.create(Object.assign({
  + url: browser.extension.getURL("assets/index.html"),
  + type: "popup"
  + }, size));
  + });
  +}
  +
  +function sizeIsValid(size) {
  + return (size && sideIsValid(size.height) && sideIsValid(size.width));
  +}
  +function sideIsValid(number) {
  + return number && number.constructor.name === "Number" && number > 50;
  }
  browser.browserAction.onClicked.addListener(openPage);
  