has_automation_equality_bug.js (1851B)
1 /** 2 * @license Apache-2.0 3 * 4 * Copyright (c) 2018 The Stdlib Authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 'use strict'; 20 21 // MODULES // 22 23 var hasOwnProp = require( '@stdlib/assert/has-own-property' ); 24 var indexOf = require( './../../index-of' ); 25 var typeOf = require( './../../type-of' ); 26 var isConstructorPrototype = require( './is_constructor_prototype.js' ); 27 var EXCLUDED_KEYS = require( './excluded_keys.json' ); 28 var win = require( './window.js' ); 29 30 31 // VARIABLES // 32 33 var bool; 34 35 36 // FUNCTIONS // 37 38 /** 39 * Determines whether an environment throws when comparing to the prototype of a value's constructor (e.g., [IE9][1]). 40 * 41 * [1]: https://stackoverflow.com/questions/7688070/why-is-comparing-the-constructor-property-of-two-windows-unreliable 42 * 43 * @private 44 * @returns {boolean} boolean indicating whether an environment is buggy 45 */ 46 function check() { 47 var k; 48 if ( typeOf( win ) === 'undefined' ) { 49 return false; 50 } 51 for ( k in win ) { // eslint-disable-line guard-for-in 52 try { 53 if ( 54 indexOf( EXCLUDED_KEYS, k ) === -1 && 55 hasOwnProp( win, k ) && 56 win[ k ] !== null && 57 typeOf( win[ k ] ) === 'object' 58 ) { 59 isConstructorPrototype( win[ k ] ); 60 } 61 } catch ( err ) { // eslint-disable-line no-unused-vars 62 return true; 63 } 64 } 65 return false; 66 } 67 68 69 // MAIN // 70 71 bool = check(); 72 73 74 // EXPORTS // 75 76 module.exports = bool;