subscription.window.js (1102B)
1 // META: title=Can subscribe and receive WebDriver BiDi events 2 // META: script=/resources/testdriver.js?feature=bidi 3 4 'use strict'; 5 6 promise_test(async () => { 7 const some_message = "SOME MESSAGE"; 8 // Subscribe to `log.entryAdded` BiDi events. This will not add a listener to the page. 9 await test_driver.bidi.log.entry_added.subscribe(); 10 // Add a listener for the log.entryAdded event. This will not subscribe to the event, so the subscription is 11 // required before. The cleanup is done automatically after the test is finished. 12 const log_entry_promise = test_driver.bidi.log.entry_added.once(); 13 // Emit a console.log message. 14 // Note: Lint rule is disabled in `lint.ignore` file. 15 console.log(some_message); 16 // Wait for the log.entryAdded event to be received. 17 const event = await log_entry_promise; 18 // Assert the log.entryAdded event has the expected message. 19 assert_equals(event.args.length, 1); 20 const event_message = event.args[0]; 21 assert_equals(event_message.value, some_message); 22 }, "Assert testdriver can subscribe and receive events");