Skip to content

testharness.js: assert_throws_dom's QuotaExceededError-by-name guard reads ame before it is assigned #62114

Description

@lahma

In assert_throws_dom_impl, the string-form branch guards against QuotaExceededError like this (current master, around L2410-2416):

} else if (typeof type === "string") {
    if (name === "QuotaExceededError") {
        throw new AssertionError("Test bug: QuotaExceededError needs to be tested for using assert_throws_quotaexceedederror().");
    }
    // ...
    name = type in codename_name_map ? codename_name_map[type] : type;

The check reads name one line before name is assigned, so at that point name is undefined and the branch can never be taken. A test calling assert_throws_dom("QuotaExceededError", ...) still gets refused - but one line later, by the unrecognized-name check (QuotaExceededError was removed from name_code_map when it became its own interface), with the message Test bug: unrecognized DOMException code name or name "QuotaExceededError" ... instead of the message that points at assert_throws_quotaexceedederror().

The refusal outcome is identical either way, so no test result changes; only the diagnostic a test author sees is wrong. The numeric branch's type === 22 guard immediately above works as intended, which suggests the string branch meant to test type as well:

if (type === "QuotaExceededError") {

(or, equivalently, the guard could move below the name assignment).

Found while porting the assertion family into an embedded engine's testharness shim (sebastienros/jint#3182), where the guard was implemented over type and the divergence from the letter of upstream is documented at the call site.

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