JavaScript externs model StorageEvent() with no type argument

Open Beginner friendly
#22,632 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
tooling, web-dev

Research direction

Start in javascript/externs/web/webstorage.js and compare the StorageEvent constructor and initStorageEvent declarations with the current Web IDL described in the issue. Update the extern signatures so the documented type and optional arguments are represented, then verify that the shown valid constructor usage is no longer modeled as zero-argument.

Written by the indexing model from the issue text.

Description

Description

javascript/externs/web/webstorage.js still models StorageEvent as a zero-argument constructor:

/**
 * @see http://www.w3.org/TR/2011/CR-webstorage-20111208/#the-storage-event
 * @extends {Event}
 * @constructor
 */
function StorageEvent() {}

Current HTML (the-storageevent-interface) defines:

constructor(DOMString type, optional StorageEventInit eventInitDict = {});

new StorageEvent('storage', { key, newValue, ... }) is valid in browsers (constructor available since 2018). CodeQL 2.27.0 reported a false positive on a standards-conforming new StorageEvent('storage', { ... }) call used in a synthetic StorageEvent test.

initStorageEvent in the same file also follows the old required-argument list; the spec method has optional arguments after type.

I searched this tracker for StorageEvent / StorageEventInit / webstorage externs and did not find an existing issue.

Reproduction

  1. Analyze JavaScript that constructs new StorageEvent('storage', { key: 'k', newValue: 'v' }).
  2. Observe a CodeQL alert that treats the constructor as taking no parameters.

Expected

Externs should match the current constructor (type plus optional StorageEventInit) so valid Web IDL usage is not flagged.

This is a modeling/false-positive report only. No exploit is claimed.

Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 11h
Merged PRs (30d)
129

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/codeql

All issues in github/codeql

Similar issues

More DevTools issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.