(message: minimalWindow, sender, sendResponse)
| 104 | } |
| 105 | |
| 106 | function minimalWindowAction(message: minimalWindow, sender, sendResponse) { |
| 107 | api.storage.get('windowId').then(winId => { |
| 108 | if (typeof winId === 'undefined') winId = 22; |
| 109 | if (chrome.windows && chrome.windows.update && chrome.windows.create) { |
| 110 | chrome.windows.update(winId, { focused: true }, function () { |
| 111 | if (chrome.runtime.lastError) { |
| 112 | const config: any = { |
| 113 | url: chrome.runtime.getURL('window.html'), |
| 114 | type: 'popup', |
| 115 | }; |
| 116 | |
| 117 | if (message.width) { |
| 118 | config.width = message.width; |
| 119 | } |
| 120 | if (message.height) { |
| 121 | config.height = message.height; |
| 122 | } |
| 123 | if (message.left) { |
| 124 | config.left = message.left; |
| 125 | } |
| 126 | |
| 127 | chrome.windows.create(config, function (win) { |
| 128 | api.storage.set('windowId', win!.id); |
| 129 | sendResponse(); |
| 130 | }); |
| 131 | } else { |
| 132 | sendResponse(); |
| 133 | } |
| 134 | }); |
| 135 | } else { |
| 136 | chrome.tabs.update(winId, { active: true }, function () { |
| 137 | if (chrome.runtime.lastError) { |
| 138 | const config: any = { |
| 139 | url: chrome.runtime.getURL('window.html'), |
| 140 | active: true, |
| 141 | }; |
| 142 | |
| 143 | chrome.tabs.create(config, function (win) { |
| 144 | api.storage.set('windowId', win!.id); |
| 145 | sendResponse(); |
| 146 | }); |
| 147 | } |
| 148 | }); |
| 149 | } |
| 150 | }); |
| 151 | return true; |
| 152 | } |
| 153 | |
| 154 | function emitterAction(message: emitter, sender, sendResponse) { |
| 155 | chrome.runtime.sendMessage(message); |
no test coverage detected