Skip to content

Commit ca9c0c1

Browse files
committed
[bidi] [js] Add realm destroyed event
1 parent fe77555 commit ca9c0c1

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

javascript/node/selenium-webdriver/bidi/scriptManager.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,10 @@ class ScriptManager {
359359
await this.subscribeAndHandleEvent('script.realmCreated', callback)
360360
}
361361

362+
async onRealmDestroyed(callback) {
363+
await this.subscribeAndHandleEvent('script.realmDestroyed', callback)
364+
}
365+
362366
async subscribeAndHandleEvent(eventType, callback) {
363367
if (this._browsingContextIds != null) {
364368
await this.bidi.subscribe(eventType, this._browsingContextIds)

javascript/node/selenium-webdriver/test/bidi/script_test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,27 @@ suite(
10061006
assert.notEqual(realmInfo.realmId, null)
10071007
assert.equal(realmInfo.realmType, RealmType.WINDOW)
10081008
})
1009+
1010+
xit('can listen to realm destroyed message', async function () {
1011+
const manager = await ScriptManager(undefined, driver)
1012+
1013+
let realmInfo = null
1014+
1015+
await manager.onRealmDestroyed((result) => {
1016+
realmInfo = result
1017+
})
1018+
1019+
const id = await driver.getWindowHandle()
1020+
const browsingContext = await BrowsingContext(driver, {
1021+
browsingContextId: id,
1022+
})
1023+
1024+
await browsingContext.close()
1025+
1026+
assert.notEqual(realmInfo, null)
1027+
assert.notEqual(realmInfo.realmId, null)
1028+
assert.equal(realmInfo.realmType, RealmType.WINDOW)
1029+
})
10091030
})
10101031
},
10111032
{browsers: [Browser.FIREFOX]}

0 commit comments

Comments
 (0)