JavaScript externs model StorageEvent() with no type argument

未关闭 适合新手
#22,632 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
84/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
javascript
领域
tooling, web-dev

调研方向

从 javascript/externs/web/webstorage.js 开始,将 StorageEvent 构造函数和 initStorageEvent 的声明与 issue 中描述的当前 Web IDL 进行比较。更新 extern 签名,使文档中说明的类型和可选参数得到表示,然后验证所示的有效构造函数用法不再被建模为零参数。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 11 小时
30 天内合并 PR
129

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

github/codeql 的其他 Issue

查看 github/codeql 的全部 Issue

相似的 Issue

更多 DevTools Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。