Open Bug 1865800 Opened 7 months ago

Warn if testdriver.js is not included but 'testdriver-command' messages are received.

Categories

(Testing :: web-platform-tests, enhancement)

enhancement

Tracking

(Not tracked)

People

(Reporter: vhilla, Unassigned)

Details

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 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 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?

You need to log in before you can comment on or make changes to this bug.