Skip to content

Commit

Permalink
[bidi] [js] Add realm destroyed event
Browse files Browse the repository at this point in the history
  • Loading branch information
pujagani committed Jan 24, 2024
1 parent fe77555 commit ca9c0c1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions javascript/node/selenium-webdriver/bidi/scriptManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ class ScriptManager {
await this.subscribeAndHandleEvent('script.realmCreated', callback)
}

async onRealmDestroyed(callback) {
await this.subscribeAndHandleEvent('script.realmDestroyed', callback)
}

async subscribeAndHandleEvent(eventType, callback) {
if (this._browsingContextIds != null) {
await this.bidi.subscribe(eventType, this._browsingContextIds)
Expand Down
21 changes: 21 additions & 0 deletions javascript/node/selenium-webdriver/test/bidi/script_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,27 @@ suite(
assert.notEqual(realmInfo.realmId, null)
assert.equal(realmInfo.realmType, RealmType.WINDOW)
})

xit('can listen to realm destroyed message', async function () {
const manager = await ScriptManager(undefined, driver)

let realmInfo = null

await manager.onRealmDestroyed((result) => {
realmInfo = result
})

const id = await driver.getWindowHandle()
const browsingContext = await BrowsingContext(driver, {
browsingContextId: id,
})

await browsingContext.close()

assert.notEqual(realmInfo, null)
assert.notEqual(realmInfo.realmId, null)
assert.equal(realmInfo.realmType, RealmType.WINDOW)
})
})
},
{browsers: [Browser.FIREFOX]}
Expand Down

0 comments on commit ca9c0c1

Please sign in to comment.