Skip to content

Commit

Permalink
New feature CALL_ON_GLOBAL, new global objects and functions relate…
Browse files Browse the repository at this point in the history
…d definitions (#53)

* Update features.js

* Update definitions.js

* Update definitions.js

* Update definitions.js

* Update features.js

* Update definitions.js

* Update definitions.js

* Update definitions.js

* Update features.js

* Update features.js

* update definitions

* update definitions

* update definitions

* update definitions

* Update src/lib/features.js

Co-authored-by: Francesco Trotta <[email protected]>

* Update src/lib/definitions.js

Co-authored-by: Francesco Trotta <[email protected]>

* Update src/lib/definitions.js

Co-authored-by: Francesco Trotta <[email protected]>

* Update src/lib/definitions.js

Co-authored-by: Francesco Trotta <[email protected]>

---------

Co-authored-by: Francesco Trotta <[email protected]>
  • Loading branch information
Clayblockunova and fasttime authored Sep 20, 2024
1 parent 59cf45c commit d1f63a7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/lib/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ function getFHPaddingEntries(index)
var AT = Feature.AT;
var ATOB = Feature.ATOB;
var BARPROP = Feature.BARPROP;
var CALL_ON_GLOBAL = Feature.CALL_ON_GLOBAL;
var CAPITAL_HTML = Feature.CAPITAL_HTML;
var CONSOLE = Feature.CONSOLE;
var DOCUMENT = Feature.DOCUMENT;
Expand Down Expand Up @@ -909,6 +910,7 @@ function getFHPaddingEntries(index)
({ expr: '(RP_3_WA + Function("return history")())[11]', optimize: true }, HISTORY),
define('(RP_1_WA + Audio)[10]', HTMLAUDIOELEMENT),
define('(RP_4_A + [].entries().filter(ANY_FUNCTION))[21]', ITERATOR_HELPER),
define({ expr: '(RP_3_WA + self.history)[11]', optimize: true }, HISTORY, SELF_OBJ),
],
'I': '"Infinity"[0]',
'J':
Expand Down Expand Up @@ -961,12 +963,15 @@ function getFHPaddingEntries(index)
LOCATION
),
define
('self[TO_STRING].call(location)[SLICE_OR_SUBSTR]("-10")[1]', LOCATION, SELF_OBJ),
define
(
'([][TO_STRING].call(location) + RP_1_WA).at("-10")',
AT,
GENERIC_ARRAY_TO_STRING,
LOCATION
),
define('(self[TO_STRING].call(location) + RP_1_WA).at("-10")', AT, LOCATION, SELF_OBJ),
],
'M':
[
Expand Down Expand Up @@ -996,6 +1001,7 @@ function getFHPaddingEntries(index)
define('btoa("".italics())[0]', ATOB),
define('(RP_0_S + Function("return statusbar")())[11]', BARPROP),
define('"0".sup()[10]', CAPITAL_HTML),
define('(RP_0_S + self.statusbar)[11]', BARPROP, SELF_OBJ),
defineCharDefault({ atob: false, charCode: false }),
],
'Q':
Expand Down Expand Up @@ -1329,6 +1335,7 @@ function getFHPaddingEntries(index)
Audio:
[
define('Function("return Audio")()', HTMLAUDIOELEMENT),
define('self.Audio', HTMLAUDIOELEMENT, SELF_OBJ),
],
Boolean:
[
Expand All @@ -1337,6 +1344,7 @@ function getFHPaddingEntries(index)
Date:
[
define('Function("return Date")()'),
define('self.Date', SELF_OBJ),
],
Function:
[
Expand All @@ -1345,10 +1353,12 @@ function getFHPaddingEntries(index)
Intl:
[
define('Function("return Intl")()', INTL),
define('self.Intl', INTL, SELF_OBJ),
],
Node:
[
define('Function("return Node")()', NODECONSTRUCTOR),
define('self.Node', NODECONSTRUCTOR, SELF_OBJ),
],
Number:
[
Expand All @@ -1371,30 +1381,37 @@ function getFHPaddingEntries(index)
atob:
[
define('Function("return atob")()', ATOB),
define('self.atob', ATOB, SELF_OBJ),
],
btoa:
[
define('Function("return btoa")()', ATOB),
define('self.btoa', ATOB, SELF_OBJ),
],
document:
[
define({ expr: 'Function("return document")()', optimize: true }, ANY_DOCUMENT),
define({ expr: 'self.document', optimize: true }, ANY_DOCUMENT, SELF_OBJ),
],
escape:
[
define({ expr: 'Function("return escape")()', optimize: true }),
define({ expr: 'self.escape', optimize: true }, SELF_OBJ),
],
location:
[
define('Function("return location")()', LOCATION),
define('self.location', LOCATION, SELF_OBJ),
],
self:
[
define('Function("return self")()', SELF_OBJ),
define('[].concat.call()[0]', CALL_ON_GLOBAL, SELF_OBJ),
],
unescape:
[
define({ expr: 'Function("return unescape")()', optimize: true }),
define({ expr: 'self.unescape', optimize: true }, SELF_OBJ),
],

// Custom definitions
Expand Down Expand Up @@ -1543,6 +1560,8 @@ function getFHPaddingEntries(index)
[
define('Function("return location")().constructor', OBJECT_L_LOCATION_CTOR),
define('Function("return location")().constructor', OLD_SAFARI_LOCATION_CTOR),
define('self.location.constructor', OBJECT_L_LOCATION_CTOR, SELF_OBJ),
define('self.location.constructor', OLD_SAFARI_LOCATION_CTOR, SELF_OBJ),
],
PLAIN_OBJECT:
[
Expand Down Expand Up @@ -1599,6 +1618,12 @@ function getFHPaddingEntries(index)
},
MOZILLA
),
define
(
{ expr: 'self.navigator.userAgent', solutionType: SolutionType.STRING },
MOZILLA,
SELF_OBJ
),
],

// Function body extra padding blocks: prepended to a function to align the function's body
Expand Down
20 changes: 19 additions & 1 deletion src/lib/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,23 @@ var featureInfos =
},
attributes: { 'web-worker': 'web-worker-restriction' },
},
CALL_ON_GLOBAL:
{
description:
'The ability to call a function on the global object when invoking ' +
'Function.prototype.call without binding.',
check:
function ()
{
try
{
if ([].concat.call()[0])
return true;
}
catch (error)
{ }
},
},
CAPITAL_HTML:
{
description:
Expand Down Expand Up @@ -890,6 +907,7 @@ var featureInfos =
[
'ANY_DOCUMENT',
'ATOB',
'CALL_ON_GLOBAL',
'CONSOLE',
'DOMWINDOW',
'ESC_HTML_ALL',
Expand All @@ -908,7 +926,7 @@ var featureInfos =
{
inherits: 'ANDRO_4_0',
versions: [['4.1',, '4.3']],
includes: { GENERIC_ARRAY_TO_STRING: true, OBJECT_UNDEFINED: true },
includes: { CALL_ON_GLOBAL: false, GENERIC_ARRAY_TO_STRING: true, OBJECT_UNDEFINED: true },
},
ANDRO_4_4:
{
Expand Down

0 comments on commit d1f63a7

Please sign in to comment.