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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
35 changes: 35 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,8 @@ 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 @@ -953,6 +956,8 @@ function getFHPaddingEntries(index)
AT,
LOCATION
),
define
('self[TO_STRING].call(___location)[SLICE_OR_SUBSTR]("-10")[1]', LOCATION, SELF_OBJ),
fasttime marked this conversation as resolved.
Show resolved Hide resolved
define('(LOCATION_CONSTRUCTOR + RP_0_S).at("-20")', AT, OLD_SAFARI_LOCATION_CTOR),
define
(
Expand All @@ -967,6 +972,13 @@ function getFHPaddingEntries(index)
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 +1008,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 +1342,7 @@ function getFHPaddingEntries(index)
Audio:
[
define('Function("return Audio")()', HTMLAUDIOELEMENT),
define('self.Audio', HTMLAUDIOELEMENT, SELF_OBJ),
],
Boolean:
[
Expand All @@ -1337,6 +1351,7 @@ function getFHPaddingEntries(index)
Date:
[
define('Function("return Date")()'),
define('self.Date', SELF_OBJ),
fasttime marked this conversation as resolved.
Show resolved Hide resolved
],
Function:
[
Expand All @@ -1345,10 +1360,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 +1388,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 +1567,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 +1625,15 @@ 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
{
[].concat.call();
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