Skip to content

An inline event attribute blanks the trace player's replay pane #393

Description

@vishnuv688

What happens

If a captured page carries an inline event attribute — <button onclick="submit()">, <body onload="…">, anything matching on* — the trace player's replay pane renders blank. The action list, filmstrip, console and metadata are all fine; only the replayed DOM is missing, and nothing is logged to explain it.

The trace itself is not at fault. The archive contains the full serialized document, the reader parses it, and the player resolves the right mutation for every row. The failure is the final render.

Why

The collector serializes an inline handler as a string attribute, which is correct — it is an attribute. Preact reads any prop whose name starts with on as an event listener and stamps its own bookkeeping property onto the value:

TypeError: Cannot create property '__a0.645…' on string
  'document.getElementById('out').textContent = …'
    at setProperty (preact/src/diff/props.js:93)
    at diffElementNodes (preact/src/diff/index.js:525)

The throw aborts the render mid-tree, so the fragment the player renders into never receives an <html> element. #renderVdom then returns at its own if (!html) return guard, the iframe is never written, and the pane stays as it was — white, silent.

One such attribute anywhere in the document is enough to blank the whole replay.

Scope

Not mobile-specific and not adapter-specific. The failing code is the shared transform in the app's replay path, so any trace from any adapter is affected as soon as the page under test uses an inline handler. It was found on an Appium mobile-web trace only because that is what was being investigated at the time (#391).

Reproducing

Capture any page containing an inline handler, e.g.

<button id="go" onclick="document.getElementById('out').textContent = 'x'">Submit</button>

then open the resulting trace.zip in the player. The Actions list populates; the replay pane stays blank.

Reproducible offline without a browser: parse the archive, run the captured document through transform, and render it with Preact into a document fragment — the render throws, and the fragment has no firstElementChild. Removing that single prop makes the same document render, body text and all.

Suggested direction

Drop string-valued on* props at the boundary between captured data and Preact. Nothing is lost by it: the replay is a static reconstruction and the player already strips <script> tags for the same reason, so a handler has nothing left to fire. A function value — which capture never produces — should be left alone so a real listener still binds.

A fix along those lines is in progress alongside #391; raising this separately because the defect stands on its own and affects desktop traces.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions