Bug 1865800 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

If a child window uses async functions such as `test_driver.set_permission` and sets the test context to `window.parent` while the parent did not include `testdriver.js`, these promises won't be resolved. I found this quite hard to debug, as tests might simply time out without any indication of what went wrong.

**Example**
The test `testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy-attribute.https.html` was synced from wpt and is broken. It raises
> Error: Tried to run in a non-testharness window without a call to set_test_context

and therefore I added `set_test_context(window.parent)`. Though the parent did not include `testdriver.js` and the test simply timed out.

The test uses `test_feature_availability` which creates an iframe with `testing/web-platform/tests/permissions-policy/resources/permissions-policy-screen-wakelock.html` which will await `test_driver.set_permission`. This calls `test_driver_internal.create_action` and [sends a message](https://searchfox.org/mozilla-central/rev/5134f3f1c7794fcff1bde59dc7b4ae65cc460919/testing/web-platform/tests/tools/wptrunner/wptrunner/testdriver-extra.js#144) to the parent, as `set_test_context` was called with `window.parent`. If `testdriver.js` is not included, the parent won't respond to the message [here](https://searchfox.org/mozilla-central/source/testing/web-platform/tests/tools/wptrunner/wptrunner/testdriver-extra.js#18) and the promise won't be resolved.

**Suggestion**
Maybe we can assert somewhere in e.g. `testharness.js` that if a `testdriver-command` is received, `window.test_driver` is not undefined? I could create a patch for this.
If a child window uses async functions such as `test_driver.set_permission` and sets the test context to `window.parent` while the parent did not include `testdriver.js`, these promises won't be resolved. I found this quite hard to debug, as tests might simply time out without any indication of what went wrong.

**Example**
The test `testing/web-platform/tests/screen-wake-lock/wakelock-enabled-by-permissions-policy-attribute.https.html` was synced from wpt and is broken. It raises
> Error: Tried to run in a non-testharness window without a call to set_test_context

and therefore I added `set_test_context(window.parent)`. Though the parent did not include `testdriver.js` and the test simply timed out.

The test uses `test_feature_availability` which creates an iframe with `testing/web-platform/tests/permissions-policy/resources/permissions-policy-screen-wakelock.html` which will await `test_driver.set_permission`. This calls `test_driver_internal.create_action` and [sends a message](https://searchfox.org/mozilla-central/rev/5134f3f1c7794fcff1bde59dc7b4ae65cc460919/testing/web-platform/tests/tools/wptrunner/wptrunner/testdriver-extra.js#144) to the parent, as `set_test_context` was called with `window.parent`. If `testdriver.js` is not included, the parent won't respond to the message [here](https://searchfox.org/mozilla-central/source/testing/web-platform/tests/tools/wptrunner/wptrunner/testdriver-extra.js#18) and the promise won't be resolved.

**Suggestion**
Maybe we can assert somewhere in e.g. `testharness.js` that if a `testdriver-command` is received, `window.test_driver` is not undefined?

Back to Bug 1865800 Comment 0