Skip to content

Commit a4bffe3

Browse files
author
Max Schaefer
committed
JavaScript: Add support for globalThis.
1 parent 9bc7ce1 commit a4bffe3

File tree

5 files changed

+9
-0
lines changed

5 files changed

+9
-0
lines changed

change-notes/1.23/analysis-javascript.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## General improvements
44

5+
* Suppor for `globalThis` has been added.
6+
57
* Support for the following frameworks and libraries has been improved:
68
- [firebase](https://www.npmjs.com/package/firebase)
79
- [mongodb](https://www.npmjs.com/package/mongodb)

javascript/ql/src/semmle/javascript/dataflow/Nodes.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ DataFlow::SourceNode globalObjectRef() {
311311
// DOM and service workers
312312
result = globalVarRef("self")
313313
or
314+
// ECMAScript 2020
315+
result = globalVarRef("globalThis")
316+
or
314317
// `require("global")`
315318
result = moduleImport("global")
316319
or

javascript/ql/test/library-tests/Nodes/globalObjectRef.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
| tst.js:4:1:4:6 | window |
1212
| tst.js:4:1:4:13 | window.window |
1313
| tst.js:5:1:5:4 | self |
14+
| tst.js:6:1:6:10 | globalThis |

javascript/ql/test/library-tests/Nodes/globalVarRef.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
| document | tst.js:3:1:3:15 | window.document |
55
| document | tst.js:4:1:4:22 | window. ... ocument |
66
| document | tst.js:5:1:5:13 | self.document |
7+
| document | tst.js:6:1:6:19 | globalThis.document |
78
| foo | tst3.js:4:1:4:5 | w.foo |
89
| global | tst2.js:7:1:7:6 | global |
910
| global | tst2.js:8:1:8:6 | global |
11+
| globalThis | tst.js:6:1:6:10 | globalThis |
1012
| goog | tst3.js:1:1:1:4 | goog |
1113
| goog | tst3.js:3:9:3:12 | goog |
1214
| self | tst.js:5:1:5:4 | self |

javascript/ql/test/library-tests/Nodes/tst.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ this;
33
window.document;
44
window.window.document;
55
self.document;
6+
globalThis.document;

0 commit comments

Comments
 (0)