diff --git a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/test-wait.js b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/test-wait.js index 8a7edb79d622..ad08ad7d76fb 100644 --- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/test-wait.js +++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/test-wait.js @@ -32,7 +32,8 @@ function wait_paints() { } function screenshot_if_ready() { - if (root.classList.contains("%(classname)s") && + if (root && + root.classList.contains("%(classname)s") && observer === null) { observer = new MutationObserver(wait_paints); observer.observe(root, {attributes: true});