Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature CALL_ON_GLOBAL, new global objects and functions related definitions #53

Merged
merged 18 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading