Closed Bug 1744928 Opened 3 years ago Closed 2 years ago

Intermittent /webdriver/tests/execute_script/arguments.py | test_element_reference[shadow-root] - AssertionError: javascript error (500): Cyclic object value

Categories

(Remote Protocol :: Marionette, defect, P5)

defect

Tracking

(firefox-esr102 wontfix, firefox109 wontfix, firefox110 wontfix, firefox111 fixed)

RESOLVED FIXED
111 Branch
Tracking Status
firefox-esr102 --- wontfix
firefox109 --- wontfix
firefox110 --- wontfix
firefox111 --- fixed

People

(Reporter: intermittent-bug-filer, Assigned: whimboo)

References

Details

(Keywords: intermittent-failure)

Filed by: hskupin [at] mozilla.com
Parsed log: https://treeherder.mozilla.org/logviewer?job_id=360489909&repo=try
Full log: https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/HrAZcTGkQBSlLfh58cduJQ/runs/0/artifacts/public/logs/live_backing.log


[task 2021-12-08T08:24:23.235Z] 08:24:23 INFO - TEST-UNEXPECTED-FAIL | /webdriver/tests/execute_script/collections.py | test_shadow_root - AssertionError: unknown error (500): TypeError: can't access property "documentElement", node.ownerDocument is null
[task 2021-12-08T08:24:23.235Z] 08:24:23 INFO - session = <Session 5d9ea162-ab8a-41dc-b966-1c0bd2ca4f83>
[task 2021-12-08T08:24:23.235Z] 08:24:23 INFO - inline = <function inline.<locals>.inline at 0x7f10bbd11d08>
[task 2021-12-08T08:24:23.235Z] 08:24:23 INFO -
[task 2021-12-08T08:24:23.235Z] 08:24:23 INFO - def test_shadow_root(session, inline):
[task 2021-12-08T08:24:23.235Z] 08:24:23 INFO - session.url = inline("""
[task 2021-12-08T08:24:23.235Z] 08:24:23 INFO - <style>
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - custom-checkbox-element {
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - display:block; width:20px; height:20px;
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - }
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - </style>
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - <custom-checkbox-element></custom-checkbox-element>
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - <script>
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - customElements.define('custom-checkbox-element',
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - class extends HTMLElement {
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - constructor() {
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - super();
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - this.attachShadow({mode: 'open'}).innerHTML = [task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - <div><input type="checkbox"/></div> [task 2021-12-08T08:24:23.236Z] 08:24:23 INFO -;
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - }
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - });
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - </script>""")
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - custom_element = session.find.css("custom-checkbox-element", all=False)
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - expected = custom_element.shadow_root
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - response = execute_script(session,
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - "return document.querySelector('custom-checkbox-element').shadowRoot")
[task 2021-12-08T08:24:23.236Z] 08:24:23 INFO - > value = assert_success(response)


Note that the same test but for `Execute Async Script` works just fine.

Here is a simple test case for Marionette that reproduces the problem. And again only for sandbox=None and not for Execute Async Script:

    def test_case(self):
        page = inline("""
        <style>
            custom-checkbox-element {
                display:block; width:20px; height:20px;
            }
        </style>
        <custom-checkbox-element id="checkbox"></custom-checkbox-element>
        <script>
            customElements.define('custom-checkbox-element',
                class extends HTMLElement {
                    constructor() {
                            super();
                            this.attachShadow({mode: 'open'}).innerHTML = `
                                <div><input type="checkbox"/></div>
                            `;
                        }
                });
        </script>""")
        self.marionette.navigate(page)

        self.marionette.execute_async_script("""
            const resolve = arguments[0];
            resolve(document.querySelector('custom-checkbox-element').shadowRoot);
        """, sandbox=None)

        self.marionette.execute_script("""
            return document.querySelector('custom-checkbox-element').shadowRoot;
        """, sandbox=None)

The exact stack of this failure is:

1639382595392 Marionette DEBUG 3 <- [1,4,{"error":"unknown error","message":"TypeError: can't access property "documentElement", node.ownerDocument is null","stacktrace":"element.isInXULDocument@chrome://remote/content/marionette/element.js:1353:1\nfrom@chrome://remote/content/marionette/element.js:1497:19\nelement.getElementId@chrome://remote/content/marionette/element.js:624:28\nevaluate.toJSON@chrome://remote/content/marionette/evaluate.js:348:20\nevaluate.toJSON@chrome://remote/content/marionette/evaluate.js:362:27\nreceiveMessage@chrome://remote/content/marionette/actors/MarionetteCommandsChild.jsm:177:31\n"},null]

The first step here would be to fix the check at:
https://searchfox.org/mozilla-central/rev/4646b826a25d3825cf209db890862b45fa09ffc3/remote/marionette/element.js#1350-1353

As it looks like there are cases when ownerDocument can be null and that's causing the above failure. But when done so we will end-up with a cyclic error.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INCOMPLETE

This is not fixed but marked as failed so it's expected to not cause failures.

Status: RESOLVED → REOPENED
Keywords: leave-open
Resolution: INCOMPLETE → ---
Depends on: 1764594

Updating the bug's summary because of the changes for the failure as triggered by landing the patch on bug 1775064.

Summary: Intermittent /webdriver/tests/execute_script/collections.py | test_shadow_root - AssertionError: unknown error (500): TypeError: can't access property "documentElement", node.ownerDocument is null → Intermittent /webdriver/tests/execute_script/collections.py | test_shadow_root - AssertionError: stale element reference (404): The element reference of [object HTMLDocument]
Status: REOPENED → NEW
Summary: Intermittent /webdriver/tests/execute_script/collections.py | test_shadow_root - AssertionError: stale element reference (404): The element reference of [object HTMLDocument] → Intermittent /webdriver/tests/execute_script/collections.py | test_shadow_root - AssertionError: stale element reference (404): The element reference of [object HTMLDocument] is stale

With bug 1793920 fixed this will no longer be a stale element reference error but a javascript error (500): Cyclic object value.

Depends on: 1793920
Summary: Intermittent /webdriver/tests/execute_script/collections.py | test_shadow_root - AssertionError: stale element reference (404): The element reference of [object HTMLDocument] is stale → Intermittent /webdriver/tests/execute_script/collections.py | test_shadow_root - AssertionError: javascript error (500): Cyclic object value

With bug 1794078 the test is moved to arguments.py

Summary: Intermittent /webdriver/tests/execute_script/collections.py | test_shadow_root - AssertionError: javascript error (500): Cyclic object value → Intermittent /webdriver/tests/execute_script/arguments.py | test_element_reference[shadow-root] - AssertionError: javascript error (500): Cyclic object value
Depends on: 1808894
No longer depends on: 1764594
Depends on: 1764594
No longer depends on: 1808894

Fixed by the patch on bug 1764594.

Assignee: nobody → hskupin
Status: NEW → RESOLVED
Closed: 3 years ago2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 111 Branch
Moving bug to Remote Protocol::Marionette component per bug 1815831.
Component: geckodriver → Marionette
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.