Skip to content

[🐛 Bug]: TypeError: header.asMap is not a function #16339

@ankianan

Description

@ankianan

Description

ProvideResponseParameters.headers() calls header.asMap(), but the Header class in the Node binding doesn’t implement asMap(), so you hit TypeError: header.asMap is not a function. (You can see the call in bidi/provideResponseParameters.js and the Header class definition in bidi/networkTypes.js.)


TypeError: header.asMap is not a function
        at /Users/ankianan/repos/ehrc-e2e-tests/tests/e2e-ui-tests/node_modules/selenium-webdriver/bidi/provideResponseParameters.js:80:49

Reproducible Code

/* eslint-disable @typescript-eslint/no-var-requires */
const { ProvideResponseParameters } = require('selenium-webdriver/bidi/provideResponseParameters');
const { BytesValue, Header } = require('selenium-webdriver/bidi/networkTypes.js');

const bufferStr = Buffer.from(JSON.stringify({})).toString("base64");

// Use Buffer.byteLength for accurate header byte count
const byteLength = Buffer.byteLength(bufferStr);

// Provide headers as Header instances using BytesValue
const headers = [
    new Header("content-type", new BytesValue("string", "application/json")),
    new Header("access-control-allow-methods", new BytesValue("string", "*")),
    new Header("access-control-allow-origin", new BytesValue("string", "*")),
    new Header("content-length", new BytesValue("string", byteLength.toString())),
];

// Use "base64" encoding for body, wrapped in BytesValue
const body = new BytesValue("base64", bufferStr);

new ProvideResponseParameters(1)
    .statusCode(200)
    .body(body)
    .headers(headers)
    .reasonPhrase("OK");

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-nodejsJavaScript BindingsI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions