-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: distinguish webidl interfaces with the extended property "Exposed"
PR-URL: #46809 Refs: #42528 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
- Loading branch information
1 parent
d0153ae
commit 41b1867
Showing
6 changed files
with
131 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
|
||
/** | ||
* This file exposes web interfaces that is defined with the WebIDL | ||
* Exposed=(Window,Worker) extended attribute or exposed in | ||
* WindowOrWorkerGlobalScope mixin. | ||
* See more details at https://webidl.spec.whatwg.org/#Exposed and | ||
* https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope. | ||
*/ | ||
|
||
const { | ||
globalThis, | ||
} = primordials; | ||
|
||
const { | ||
defineOperation, | ||
defineLazyProperties, | ||
defineReplaceableLazyAttribute, | ||
exposeLazyInterfaces, | ||
} = require('internal/util'); | ||
|
||
// https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope | ||
const timers = require('timers'); | ||
defineOperation(globalThis, 'clearInterval', timers.clearInterval); | ||
defineOperation(globalThis, 'clearTimeout', timers.clearTimeout); | ||
defineOperation(globalThis, 'setInterval', timers.setInterval); | ||
defineOperation(globalThis, 'setTimeout', timers.setTimeout); | ||
|
||
// https://html.spec.whatwg.org/multipage/web-messaging.html#broadcasting-to-other-browsing-contexts | ||
exposeLazyInterfaces(globalThis, 'internal/worker/io', ['BroadcastChannel']); | ||
exposeLazyInterfaces(globalThis, 'internal/worker/io', [ | ||
'MessageChannel', 'MessagePort', 'MessageEvent', | ||
]); | ||
defineLazyProperties(globalThis, 'buffer', ['atob', 'btoa']); | ||
// https://www.w3.org/TR/FileAPI/#dfn-Blob | ||
exposeLazyInterfaces(globalThis, 'internal/blob', ['Blob']); | ||
// https://www.w3.org/TR/hr-time-2/#the-performance-attribute | ||
exposeLazyInterfaces(globalThis, 'perf_hooks', [ | ||
'Performance', 'PerformanceEntry', 'PerformanceMark', 'PerformanceMeasure', | ||
'PerformanceObserver', 'PerformanceObserverEntryList', 'PerformanceResourceTiming', | ||
]); | ||
|
||
defineReplaceableLazyAttribute(globalThis, 'perf_hooks', ['performance']); | ||
|
||
// https://w3c.github.io/FileAPI/#creating-revoking | ||
const { installObjectURLMethods } = require('internal/url'); | ||
installObjectURLMethods(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters