Skip to content

Commit

Permalink
Add check for the prepared state
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Jan 8, 2020
1 parent 585bef7 commit d98f0e5
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions webextensions/tests/test-new-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,30 @@ export async function testReopenedWithPositionByAnotherAddonImmediatelyWhileCrea
}, { windowId: win.id });

let onCreated;
const promisedTabReopenedByAnotherAddon = new Promise((resolve, _reject) => {
const promisedTabReopenedByAnotherAddon = new Promise((resolve, reject) => {
onCreated = async tab => {
browser.tabs.onCreated.removeListener(onCreated);
// wait until the tab is attached by TST
while (true) {
tab = await browser.tabs.get(tab.id);
if (tab.openerTabId)
break;
await wait(1);
}
try {
const preparedTabs = await Utils.refreshTabs({ A: tabs.A, B: tabs.B, C: tab });
{
const { A, B, C } = preparedTabs;
is([
`${A.id}`,
`${A.id} => ${C.id}`,
`${B.id}`
], Utils.treeStructure([A, C, B]),
'tabs must be initialized with specified structure');
}
}
catch(e) {
reject(e);
return;
}
// one more wait, to simulate behavior by another addon
await wait(1);
Expand Down

0 comments on commit d98f0e5

Please sign in to comment.