diff --git a/Features.md b/Features.md index c1b1295a..41692ced 100644 --- a/Features.md +++ b/Features.md @@ -42,8 +42,9 @@ This table lists features available in the most common engines.
  • NO_IE_SRC (implied by V8_SRC)
  • NO_OLD_SAFARI_ARRAY_ITERATOR
  • OBJECT_UNDEFINED (implied by GLOBAL_UNDEFINED) +
  • OBJECT_W_SELF (implied by WINDOW)
  • REGEXP_STRING_ITERATOR -
  • SELF_OBJ (implied by ANY_WINDOW and WINDOW) +
  • SELF_OBJ (implied by ANY_WINDOW, OBJECT_W_SELF, and WINDOW)
  • STATUS
  • UNDEFINED (implied by GLOBAL_UNDEFINED and OBJECT_UNDEFINED)
  • V8_SRC @@ -89,8 +90,9 @@ This table lists features available in the most common engines.
  • NO_V8_SRC (implied by FF_SRC)
  • OBJECT_ARRAY_ENTRIES_CTOR
  • OBJECT_UNDEFINED (implied by GLOBAL_UNDEFINED) +
  • OBJECT_W_SELF (implied by WINDOW)
  • REGEXP_STRING_ITERATOR -
  • SELF_OBJ (implied by ANY_WINDOW and WINDOW) +
  • SELF_OBJ (implied by ANY_WINDOW, OBJECT_W_SELF, and WINDOW)
  • SHORT_LOCALES
  • STATUS
  • UNDEFINED (implied by GLOBAL_UNDEFINED and OBJECT_UNDEFINED) @@ -125,8 +127,9 @@ This table lists features available in the most common engines.
  • NO_V8_SRC (implied by IE_SRC)
  • OBJECT_L_LOCATION_CTOR
  • OBJECT_UNDEFINED (Internet Explorer 10+) +
  • OBJECT_W_SELF (implied by WINDOW)
  • PLAIN_INTL (Internet Explorer 11) -
  • SELF_OBJ (implied by ANY_WINDOW and WINDOW) +
  • SELF_OBJ (implied by ANY_WINDOW, OBJECT_W_SELF, and WINDOW)
  • SHORT_LOCALES (Internet Explorer 11)
  • STATUS
  • UNDEFINED (implied by OBJECT_UNDEFINED) @@ -176,10 +179,11 @@ This table lists features available in the most common engines.
  • OBJECT_ARRAY_ENTRIES_CTOR (Safari 9+)
  • OBJECT_L_LOCATION_CTOR (not in Safari 10.0+)
  • OBJECT_UNDEFINED (implied by GLOBAL_UNDEFINED) +
  • OBJECT_W_SELF (implied by WINDOW)
  • OLD_SAFARI_LOCATION_CTOR (not in Safari 10.0+)
  • PLAIN_INTL (Safari 10.0+, not in Safari 14.0.1+)
  • REGEXP_STRING_ITERATOR (Safari 13+) -
  • SELF_OBJ (implied by ANY_WINDOW and WINDOW) +
  • SELF_OBJ (implied by ANY_WINDOW, OBJECT_W_SELF, and WINDOW)
  • SHORT_LOCALES (Safari 10.0+)
  • STATUS
  • UNDEFINED (implied by GLOBAL_UNDEFINED and OBJECT_UNDEFINED) @@ -215,8 +219,9 @@ This table lists features available in the most common engines.
  • NO_FF_SRC (implied by V8_SRC)
  • NO_IE_SRC (implied by HTMLAUDIOELEMENT and V8_SRC)
  • OBJECT_UNDEFINED (Android Browser 4.1+) +
  • OBJECT_W_SELF (implied by WINDOW; Android Browser 4.4)
  • PLAIN_INTL (Android Browser 4.4) -
  • SELF_OBJ (implied by ANY_WINDOW, DOMWINDOW, and WINDOW) +
  • SELF_OBJ (implied by ANY_WINDOW, DOMWINDOW, OBJECT_W_SELF, and WINDOW)
  • SHORT_LOCALES (Android Browser 4.4)
  • STATUS
  • UNDEFINED (implied by OBJECT_UNDEFINED; Android Browser 4.1+) diff --git a/api-doc/interfaces/FeatureAll.md b/api-doc/interfaces/FeatureAll.md index 200a02f1..63fda7ab 100644 --- a/api-doc/interfaces/FeatureAll.md +++ b/api-doc/interfaces/FeatureAll.md @@ -854,6 +854,18 @@ Available in Chrome, Edge, Firefox, Internet Explorer 10+, Safari, Opera, Androi *** +### OBJECT\_W\_SELF + +> **OBJECT\_W\_SELF**: [`ElementaryFeature`](ElementaryFeature.md) + +The property that the string representation of the global object self starts with "\[object W". + +#### Remarks + +Available in Chrome, Edge, Firefox, Internet Explorer, Safari, Opera, and Android Browser 4.4. This feature is not available inside web workers in Chrome, Edge, Firefox, Safari, Opera, and Android Browser 4.4. + +*** + ### OLD\_SAFARI\_LOCATION\_CTOR > **OLD\_SAFARI\_LOCATION\_CTOR**: [`ElementaryFeature`](ElementaryFeature.md) diff --git a/api-doc/interfaces/FeatureConstructor.md b/api-doc/interfaces/FeatureConstructor.md index cacfeb41..d240824a 100644 --- a/api-doc/interfaces/FeatureConstructor.md +++ b/api-doc/interfaces/FeatureConstructor.md @@ -1276,6 +1276,22 @@ Available in Chrome, Edge, Firefox, Internet Explorer 10+, Safari, Opera, Androi *** +### OBJECT\_W\_SELF + +> **OBJECT\_W\_SELF**: [`ElementaryFeature`](ElementaryFeature.md) + +The property that the string representation of the global object self starts with "\[object W". + +#### Remarks + +Available in Chrome, Edge, Firefox, Internet Explorer, Safari, Opera, and Android Browser 4.4. This feature is not available inside web workers in Chrome, Edge, Firefox, Safari, Opera, and Android Browser 4.4. + +#### Inherited from + +[`FeatureAll`](FeatureAll.md).[`OBJECT_W_SELF`](FeatureAll.md#object_w_self) + +*** + ### OLD\_SAFARI\_LOCATION\_CTOR > **OLD\_SAFARI\_LOCATION\_CTOR**: [`ElementaryFeature`](ElementaryFeature.md) diff --git a/api-doc/type-aliases/ElementaryFeatureName.md b/api-doc/type-aliases/ElementaryFeatureName.md index f89190a0..2d128dfc 100644 --- a/api-doc/type-aliases/ElementaryFeatureName.md +++ b/api-doc/type-aliases/ElementaryFeatureName.md @@ -4,6 +4,6 @@ # Type Alias: ElementaryFeatureName -> **ElementaryFeatureName**: `"ANY_DOCUMENT"` \| `"ANY_WINDOW"` \| `"ARRAY_ITERATOR"` \| `"ARROW"` \| `"ASYNC_FUNCTION"` \| `"AT"` \| `"ATOB"` \| `"BARPROP"` \| `"CAPITAL_HTML"` \| `"CONSOLE"` \| `"DOCUMENT"` \| `"DOMWINDOW"` \| `"ESC_HTML_ALL"` \| `"ESC_HTML_QUOT"` \| `"ESC_HTML_QUOT_ONLY"` \| `"ESC_REGEXP_LF"` \| `"ESC_REGEXP_SLASH"` \| `"FF_SRC"` \| `"FILL"` \| `"FLAT"` \| `"FROM_CODE_POINT"` \| `"FUNCTION_19_LF"` \| `"FUNCTION_22_LF"` \| `"GENERIC_ARRAY_TO_STRING"` \| `"GLOBAL_UNDEFINED"` \| `"GMT"` \| `"HISTORY"` \| `"HTMLAUDIOELEMENT"` \| `"IE_SRC"` \| `"INCR_CHAR"` \| `"INTL"` \| `"ITERATOR_HELPER"` \| `"JAPANESE_INFINITY"` \| `"LOCALE_INFINITY"` \| `"LOCALE_NUMERALS"` \| `"LOCALE_NUMERALS_EXT"` \| `"LOCATION"` \| `"NAME"` \| `"NODECONSTRUCTOR"` \| `"NO_FF_SRC"` \| `"NO_IE_SRC"` \| `"NO_OLD_SAFARI_ARRAY_ITERATOR"` \| `"NO_V8_SRC"` \| `"OBJECT_ARRAY_ENTRIES_CTOR"` \| `"OBJECT_L_LOCATION_CTOR"` \| `"OBJECT_UNDEFINED"` \| `"OLD_SAFARI_LOCATION_CTOR"` \| `"PLAIN_INTL"` \| `"REGEXP_STRING_ITERATOR"` \| `"SELF_OBJ"` \| `"SHORT_LOCALES"` \| `"STATUS"` \| `"UNDEFINED"` \| `"V8_SRC"` \| `"WINDOW"` +> **ElementaryFeatureName**: `"ANY_DOCUMENT"` \| `"ANY_WINDOW"` \| `"ARRAY_ITERATOR"` \| `"ARROW"` \| `"ASYNC_FUNCTION"` \| `"AT"` \| `"ATOB"` \| `"BARPROP"` \| `"CAPITAL_HTML"` \| `"CONSOLE"` \| `"DOCUMENT"` \| `"DOMWINDOW"` \| `"ESC_HTML_ALL"` \| `"ESC_HTML_QUOT"` \| `"ESC_HTML_QUOT_ONLY"` \| `"ESC_REGEXP_LF"` \| `"ESC_REGEXP_SLASH"` \| `"FF_SRC"` \| `"FILL"` \| `"FLAT"` \| `"FROM_CODE_POINT"` \| `"FUNCTION_19_LF"` \| `"FUNCTION_22_LF"` \| `"GENERIC_ARRAY_TO_STRING"` \| `"GLOBAL_UNDEFINED"` \| `"GMT"` \| `"HISTORY"` \| `"HTMLAUDIOELEMENT"` \| `"IE_SRC"` \| `"INCR_CHAR"` \| `"INTL"` \| `"ITERATOR_HELPER"` \| `"JAPANESE_INFINITY"` \| `"LOCALE_INFINITY"` \| `"LOCALE_NUMERALS"` \| `"LOCALE_NUMERALS_EXT"` \| `"LOCATION"` \| `"NAME"` \| `"NODECONSTRUCTOR"` \| `"NO_FF_SRC"` \| `"NO_IE_SRC"` \| `"NO_OLD_SAFARI_ARRAY_ITERATOR"` \| `"NO_V8_SRC"` \| `"OBJECT_ARRAY_ENTRIES_CTOR"` \| `"OBJECT_L_LOCATION_CTOR"` \| `"OBJECT_UNDEFINED"` \| `"OBJECT_W_SELF"` \| `"OLD_SAFARI_LOCATION_CTOR"` \| `"PLAIN_INTL"` \| `"REGEXP_STRING_ITERATOR"` \| `"SELF_OBJ"` \| `"SHORT_LOCALES"` \| `"STATUS"` \| `"UNDEFINED"` \| `"V8_SRC"` \| `"WINDOW"` Name of an elementary feature. diff --git a/src/lib/features.js b/src/lib/features.js index b35f087d..e8422583 100644 --- a/src/lib/features.js +++ b/src/lib/features.js @@ -13,21 +13,6 @@ function checkLocaleNumeral(locale, number, regExp) return returnValue; } -function checkSelfFeature() -{ - // self + '' throws an error inside a web worker in Safari 8 and 9. - try - { - var str = self + ''; - } - catch (error) - { - return false; - } - var available = this(str); - return available; -} - function describeEngine(engine) { var description = 'Features available in ' + engine + '.'; @@ -53,6 +38,26 @@ function isExcludingAttribute(restrictionCache, restrictionName, featureObjs) return returnValue; } +function makeSelfFeatureCheck(regExp) +{ + function check() + { + // self + '' throws an error inside a web worker in Safari 8 and 9. + try + { + var str = self + ''; + } + catch (error) + { + return false; + } + var available = regExp.test(str); + return available; + } + + return check; +} + function restrict(environment, engineFeatureObjs) { var restrictionCache = createEmpty(); @@ -104,15 +109,7 @@ var featureInfos = description: 'Existence of the global object self whose string representation starts with "[object " ' + 'and ends with "Window]".', - check: - checkSelfFeature.bind - ( - function (str) - { - var available = /^\[object [\S\s]*Window]$/.test(str); - return available; - } - ), + check: makeSelfFeatureCheck(/^\[object [\S\s]*Window]$/), includes: ['SELF_OBJ'], attributes: { 'web-worker': 'web-worker-restriction' }, }, @@ -247,15 +244,7 @@ var featureInfos = description: 'Existence of the global object self having the string representation "[object ' + 'DOMWindow]".', - check: - checkSelfFeature.bind - ( - function (str) - { - var available = str === '[object DOMWindow]'; - return available; - } - ), + check: makeSelfFeatureCheck(/^\[object DOMWindow]$/), includes: ['ANY_WINDOW'], excludes: ['OBJECT_W_SELF'], attributes: { 'web-worker': 'web-worker-restriction' }, @@ -510,7 +499,7 @@ var featureInfos = check: function () { - var available = Infinity.toLocaleString('ja').slice(-1) === '∞'; + var available = /∞$/.test(Infinity.toLocaleString('ja')); return available; }, }, @@ -535,7 +524,6 @@ var featureInfos = function () { var available = - Number.prototype.toLocaleString && checkLocaleNumeral('ar', NaN, /^ليس/) && checkLocaleNumeral('ar-td', 234567890.1, /^٢٣٤٬?٥٦٧٬?٨٩٠٫١/) && checkLocaleNumeral('fa', 1234567890, /^۱٬۲۳۴٬۵۶۷٬۸۹۰/); @@ -554,7 +542,6 @@ var featureInfos = function () { var available = - Number.prototype.toLocaleString && checkLocaleNumeral('ar', NaN, /^ليس.رقم/) && checkLocaleNumeral('ar-td', 234567890.1, /^٢٣٤٬?٥٦٧٬?٨٩٠٫١/) && checkLocaleNumeral('bn', 1234567890, /^১,২৩,৪৫,৬৭,৮৯০/) && @@ -706,15 +693,7 @@ var featureInfos = description: 'The property that the string representation of the global object self starts ' + 'with "[object W".', - check: - checkSelfFeature.bind - ( - function (str) - { - var available = /^\[object W/.test(str); - return available; - } - ), + check: makeSelfFeatureCheck(/^\[object W/), includes: ['SELF_OBJ'], excludes: ['DOMWINDOW'], attributes: { 'web-worker': 'non-ie-restriction' }, @@ -764,15 +743,7 @@ var featureInfos = { description: 'Existence of the global object self whose string representation starts with "[object ".', - check: - checkSelfFeature.bind - ( - function (str) - { - var available = /^\[object /.test(str); - return available; - } - ), + check: makeSelfFeatureCheck(/^\[object /), attributes: { 'web-worker': 'safari-bug-21820506' }, }, SHORT_LOCALES: @@ -830,15 +801,7 @@ var featureInfos = { description: 'Existence of the global object self having the string representation "[object Window]".', - check: - checkSelfFeature.bind - ( - function (str) - { - var available = str === '[object Window]'; - return available; - } - ), + check: makeSelfFeatureCheck(/^\[object Window]$/), includes: ['ANY_WINDOW', 'OBJECT_W_SELF'], attributes: { 'web-worker': 'web-worker-restriction' }, },