diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-02-12 21:45:47 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-02-12 22:03:16 +0900 |
commit | cf03d278eb8bb8f7544ae6395b76e1a1e0781053 (patch) | |
tree | 8df925c5d35ea0f5635c67c49aed6382eefd0061 /e2e | |
parent | 8d3c79c63a6d05b6c19e40fb438c7b900ef70a55 (diff) |
add util to wait for tab loading
Diffstat (limited to 'e2e')
-rw-r--r-- | e2e/ambassador/src/background/tabs.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/e2e/ambassador/src/background/tabs.js b/e2e/ambassador/src/background/tabs.js new file mode 100644 index 0000000..93d47a3 --- /dev/null +++ b/e2e/ambassador/src/background/tabs.js @@ -0,0 +1,18 @@ +const create = (props = {}) => { + return new Promise((resolve) => { + browser.tabs.create(props).then((createdTab) => { + let callback = (tabId, changeInfo, tab) => { + if (tab.url !== 'about:blank' && tabId === createdTab.id && + changeInfo.status === 'complete') { + browser.tabs.onUpdated.removeListener(callback); + resolve(tab); + } + }; + browser.tabs.onUpdated.addListener(callback); + }); + }); +}; + +export { + create, +}; |