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 摘要。