2019-02-18 18:02:38 +00:00
|
|
|
QUnit.module( "support", { afterEach: moduleTeardown } );
|
2011-05-10 10:23:53 +00:00
|
|
|
|
2013-08-26 22:54:13 +00:00
|
|
|
var computedSupport = getComputedSupport( jQuery.support );
|
|
|
|
|
|
|
|
function getComputedSupport( support ) {
|
|
|
|
var prop,
|
|
|
|
result = {};
|
|
|
|
|
|
|
|
for ( prop in support ) {
|
|
|
|
if ( typeof support[ prop ] === "function" ) {
|
|
|
|
result[ prop ] = support[ prop ]();
|
|
|
|
} else {
|
|
|
|
result[ prop ] = support[ prop ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-06-11 01:54:16 +00:00
|
|
|
if ( jQuery.css ) {
|
2016-04-10 19:42:44 +00:00
|
|
|
testIframe(
|
2015-08-16 03:45:28 +00:00
|
|
|
"body background is not lost if set prior to loading jQuery (#9239)",
|
|
|
|
"support/bodyBackground.html",
|
2016-04-10 19:42:44 +00:00
|
|
|
function( assert, jQuery, window, document, color, support ) {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.expect( 2 );
|
|
|
|
var okValue = {
|
|
|
|
"#000000": true,
|
|
|
|
"rgb(0, 0, 0)": true
|
|
|
|
};
|
|
|
|
assert.ok( okValue[ color ], "color was not reset (" + color + ")" );
|
2011-10-31 22:24:34 +00:00
|
|
|
|
2016-01-27 11:13:32 +00:00
|
|
|
assert.deepEqual( jQuery.extend( {}, support ), computedSupport,
|
|
|
|
"Same support properties" );
|
2015-08-16 03:45:28 +00:00
|
|
|
}
|
|
|
|
);
|
2012-06-11 01:54:16 +00:00
|
|
|
}
|
2011-08-04 22:56:49 +00:00
|
|
|
|
2014-12-15 00:48:53 +00:00
|
|
|
// This test checks CSP only for browsers with "Content-Security-Policy" header support
|
2013-10-30 12:20:38 +00:00
|
|
|
// i.e. no old WebKit or old Firefox
|
2016-04-10 19:42:44 +00:00
|
|
|
testIframe(
|
2015-08-16 03:45:28 +00:00
|
|
|
"Check CSP (https://developer.mozilla.org/en-US/docs/Security/CSP) restrictions",
|
2017-08-01 16:52:45 +00:00
|
|
|
"mock.php?action=cspFrame",
|
2016-04-10 19:42:44 +00:00
|
|
|
function( assert, jQuery, window, document, support ) {
|
2015-09-08 00:26:29 +00:00
|
|
|
var done = assert.async();
|
|
|
|
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.expect( 2 );
|
2016-01-27 11:13:32 +00:00
|
|
|
assert.deepEqual( jQuery.extend( {}, support ), computedSupport,
|
|
|
|
"No violations of CSP polices" );
|
2013-10-30 12:20:38 +00:00
|
|
|
|
2017-08-01 16:52:45 +00:00
|
|
|
supportjQuery.get( baseURL + "support/csp.log" ).done( function( data ) {
|
2015-08-16 03:45:28 +00:00
|
|
|
assert.equal( data, "", "No log request should be sent" );
|
2017-08-01 16:52:45 +00:00
|
|
|
supportjQuery.get( baseURL + "mock.php?action=cspClean" ).done( done );
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2013-10-30 12:20:38 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
( function() {
|
2017-05-15 18:37:14 +00:00
|
|
|
var expected,
|
2018-04-23 12:16:21 +00:00
|
|
|
userAgent = window.navigator.userAgent,
|
|
|
|
expectedMap = {
|
|
|
|
edge: {
|
|
|
|
"ajax": true,
|
|
|
|
"boxSizingReliable": true,
|
|
|
|
"checkClone": true,
|
|
|
|
"checkOn": true,
|
|
|
|
"clearCloneStyle": true,
|
|
|
|
"cors": true,
|
|
|
|
"createHTMLDocument": true,
|
|
|
|
"focusin": false,
|
|
|
|
"noCloneChecked": true,
|
|
|
|
"optSelected": true,
|
|
|
|
"pixelBoxStyles": true,
|
|
|
|
"pixelPosition": true,
|
|
|
|
"radioValue": true,
|
|
|
|
"reliableMarginLeft": true,
|
|
|
|
"scrollboxSize": true
|
|
|
|
},
|
|
|
|
ie_10_11: {
|
|
|
|
"ajax": true,
|
|
|
|
"boxSizingReliable": false,
|
|
|
|
"checkClone": true,
|
|
|
|
"checkOn": true,
|
|
|
|
"clearCloneStyle": false,
|
|
|
|
"cors": true,
|
|
|
|
"createHTMLDocument": true,
|
|
|
|
"focusin": true,
|
|
|
|
"noCloneChecked": false,
|
|
|
|
"optSelected": false,
|
|
|
|
"pixelBoxStyles": true,
|
|
|
|
"pixelPosition": true,
|
|
|
|
"radioValue": false,
|
|
|
|
"reliableMarginLeft": true,
|
|
|
|
"scrollboxSize": true
|
|
|
|
},
|
|
|
|
ie_9: {
|
|
|
|
"ajax": true,
|
|
|
|
"boxSizingReliable": false,
|
|
|
|
"checkClone": true,
|
|
|
|
"checkOn": true,
|
|
|
|
"clearCloneStyle": false,
|
|
|
|
"cors": false,
|
|
|
|
"createHTMLDocument": true,
|
|
|
|
"focusin": true,
|
|
|
|
"noCloneChecked": false,
|
|
|
|
"optSelected": false,
|
|
|
|
"pixelBoxStyles": true,
|
|
|
|
"pixelPosition": true,
|
|
|
|
"radioValue": false,
|
|
|
|
"reliableMarginLeft": true,
|
2018-10-08 16:25:15 +00:00
|
|
|
"scrollboxSize": false
|
2018-04-23 12:16:21 +00:00
|
|
|
},
|
|
|
|
chrome: {
|
|
|
|
"ajax": true,
|
|
|
|
"boxSizingReliable": true,
|
|
|
|
"checkClone": true,
|
|
|
|
"checkOn": true,
|
|
|
|
"clearCloneStyle": true,
|
|
|
|
"cors": true,
|
|
|
|
"createHTMLDocument": true,
|
|
|
|
"focusin": false,
|
|
|
|
"noCloneChecked": true,
|
|
|
|
"optSelected": true,
|
|
|
|
"pixelBoxStyles": true,
|
|
|
|
"pixelPosition": true,
|
|
|
|
"radioValue": true,
|
|
|
|
"reliableMarginLeft": true,
|
|
|
|
"scrollboxSize": true
|
|
|
|
},
|
2018-11-12 17:55:47 +00:00
|
|
|
safari: {
|
2018-04-23 12:16:21 +00:00
|
|
|
"ajax": true,
|
|
|
|
"boxSizingReliable": true,
|
|
|
|
"checkClone": true,
|
|
|
|
"checkOn": true,
|
|
|
|
"clearCloneStyle": true,
|
|
|
|
"cors": true,
|
|
|
|
"createHTMLDocument": true,
|
|
|
|
"focusin": false,
|
|
|
|
"noCloneChecked": true,
|
|
|
|
"optSelected": true,
|
|
|
|
"pixelBoxStyles": true,
|
|
|
|
"pixelPosition": true,
|
|
|
|
"radioValue": true,
|
|
|
|
"reliableMarginLeft": true,
|
|
|
|
"scrollboxSize": true
|
|
|
|
},
|
|
|
|
safari_9_10: {
|
|
|
|
"ajax": true,
|
|
|
|
"boxSizingReliable": true,
|
|
|
|
"checkClone": true,
|
|
|
|
"checkOn": true,
|
|
|
|
"clearCloneStyle": true,
|
|
|
|
"cors": true,
|
|
|
|
"createHTMLDocument": true,
|
|
|
|
"focusin": false,
|
|
|
|
"noCloneChecked": true,
|
|
|
|
"optSelected": true,
|
|
|
|
"pixelBoxStyles": false,
|
|
|
|
"pixelPosition": false,
|
|
|
|
"radioValue": true,
|
|
|
|
"reliableMarginLeft": true,
|
|
|
|
"scrollboxSize": true
|
|
|
|
},
|
2018-11-12 17:54:15 +00:00
|
|
|
firefox: {
|
2018-04-23 12:16:21 +00:00
|
|
|
"ajax": true,
|
|
|
|
"boxSizingReliable": true,
|
|
|
|
"checkClone": true,
|
|
|
|
"checkOn": true,
|
|
|
|
"clearCloneStyle": true,
|
|
|
|
"cors": true,
|
|
|
|
"createHTMLDocument": true,
|
|
|
|
"focusin": false,
|
|
|
|
"noCloneChecked": true,
|
|
|
|
"optSelected": true,
|
|
|
|
"pixelBoxStyles": true,
|
|
|
|
"pixelPosition": true,
|
|
|
|
"radioValue": true,
|
2018-11-12 17:54:15 +00:00
|
|
|
"reliableMarginLeft": true,
|
2018-04-23 12:16:21 +00:00
|
|
|
"scrollboxSize": true
|
|
|
|
},
|
2018-11-12 17:54:15 +00:00
|
|
|
firefox_60: {
|
2018-07-09 16:37:52 +00:00
|
|
|
"ajax": true,
|
|
|
|
"boxSizingReliable": true,
|
|
|
|
"checkClone": true,
|
|
|
|
"checkOn": true,
|
|
|
|
"clearCloneStyle": true,
|
|
|
|
"cors": true,
|
|
|
|
"createHTMLDocument": true,
|
|
|
|
"focusin": false,
|
|
|
|
"noCloneChecked": true,
|
|
|
|
"optSelected": true,
|
|
|
|
"pixelBoxStyles": true,
|
|
|
|
"pixelPosition": true,
|
|
|
|
"radioValue": true,
|
2018-11-12 17:54:15 +00:00
|
|
|
"reliableMarginLeft": false,
|
2018-07-09 16:37:52 +00:00
|
|
|
"scrollboxSize": true
|
|
|
|
},
|
2018-11-12 17:55:47 +00:00
|
|
|
ios: {
|
2018-04-23 12:16:21 +00:00
|
|
|
"ajax": true,
|
|
|
|
"boxSizingReliable": true,
|
|
|
|
"checkClone": true,
|
|
|
|
"checkOn": true,
|
|
|
|
"clearCloneStyle": true,
|
|
|
|
"cors": true,
|
|
|
|
"createHTMLDocument": true,
|
|
|
|
"focusin": false,
|
|
|
|
"noCloneChecked": true,
|
|
|
|
"optSelected": true,
|
|
|
|
"pixelBoxStyles": true,
|
|
|
|
"pixelPosition": true,
|
|
|
|
"radioValue": true,
|
|
|
|
"reliableMarginLeft": true,
|
|
|
|
"scrollboxSize": true
|
|
|
|
},
|
|
|
|
ios_9_10: {
|
|
|
|
"ajax": true,
|
|
|
|
"boxSizingReliable": true,
|
|
|
|
"checkClone": true,
|
|
|
|
"checkOn": true,
|
|
|
|
"clearCloneStyle": true,
|
|
|
|
"cors": true,
|
|
|
|
"createHTMLDocument": true,
|
|
|
|
"focusin": false,
|
|
|
|
"noCloneChecked": true,
|
|
|
|
"optSelected": true,
|
|
|
|
"pixelBoxStyles": false,
|
|
|
|
"pixelPosition": false,
|
|
|
|
"radioValue": true,
|
|
|
|
"reliableMarginLeft": true,
|
|
|
|
"scrollboxSize": true
|
|
|
|
},
|
|
|
|
ios_8: {
|
|
|
|
"ajax": true,
|
|
|
|
"boxSizingReliable": true,
|
|
|
|
"checkClone": true,
|
|
|
|
"checkOn": true,
|
|
|
|
"clearCloneStyle": true,
|
|
|
|
"cors": true,
|
|
|
|
"createHTMLDocument": false,
|
|
|
|
"focusin": false,
|
|
|
|
"noCloneChecked": true,
|
|
|
|
"optSelected": true,
|
|
|
|
"pixelBoxStyles": false,
|
|
|
|
"pixelPosition": false,
|
|
|
|
"radioValue": true,
|
|
|
|
"reliableMarginLeft": true,
|
|
|
|
"scrollboxSize": true
|
|
|
|
},
|
|
|
|
ios_7: {
|
|
|
|
"ajax": true,
|
|
|
|
"boxSizingReliable": true,
|
|
|
|
"checkClone": true,
|
|
|
|
"checkOn": true,
|
|
|
|
"clearCloneStyle": true,
|
|
|
|
"cors": true,
|
|
|
|
"createHTMLDocument": true,
|
|
|
|
"focusin": false,
|
|
|
|
"noCloneChecked": true,
|
|
|
|
"optSelected": true,
|
|
|
|
"pixelBoxStyles": false,
|
|
|
|
"pixelPosition": false,
|
|
|
|
"radioValue": true,
|
|
|
|
"reliableMarginLeft": true,
|
|
|
|
"scrollboxSize": true
|
|
|
|
},
|
|
|
|
android: {
|
|
|
|
"ajax": true,
|
|
|
|
"boxSizingReliable": true,
|
|
|
|
"checkClone": false,
|
|
|
|
"checkOn": false,
|
|
|
|
"clearCloneStyle": true,
|
|
|
|
"cors": true,
|
|
|
|
"createHTMLDocument": true,
|
|
|
|
"focusin": false,
|
|
|
|
"noCloneChecked": true,
|
|
|
|
"optSelected": true,
|
|
|
|
"pixelBoxStyles": false,
|
|
|
|
"pixelPosition": false,
|
|
|
|
"radioValue": true,
|
|
|
|
"reliableMarginLeft": false,
|
|
|
|
"scrollboxSize": true
|
|
|
|
}
|
|
|
|
};
|
2013-03-07 14:15:12 +00:00
|
|
|
|
2015-06-16 12:44:24 +00:00
|
|
|
if ( /edge\//i.test( userAgent ) ) {
|
2018-04-23 12:16:21 +00:00
|
|
|
expected = expectedMap.edge;
|
2014-12-09 20:05:31 +00:00
|
|
|
} else if ( /(msie 10\.0|trident\/7\.0)/i.test( userAgent ) ) {
|
2018-04-23 12:16:21 +00:00
|
|
|
expected = expectedMap.ie_10_11;
|
2013-03-07 14:15:12 +00:00
|
|
|
} else if ( /msie 9\.0/i.test( userAgent ) ) {
|
2018-04-23 12:16:21 +00:00
|
|
|
expected = expectedMap.ie_9;
|
2015-06-13 22:50:05 +00:00
|
|
|
} else if ( /chrome/i.test( userAgent ) ) {
|
2015-08-16 06:59:58 +00:00
|
|
|
|
2015-06-13 22:50:05 +00:00
|
|
|
// Catches Chrome on Android as well (i.e. the default
|
|
|
|
// Android browser on Android >= 4.4).
|
2018-04-23 12:16:21 +00:00
|
|
|
expected = expectedMap.chrome;
|
2019-09-23 17:28:43 +00:00
|
|
|
} else if ( /\b(?:9|10)\.\d+(\.\d+)* safari/i.test( userAgent ) ) {
|
2018-04-23 12:16:21 +00:00
|
|
|
expected = expectedMap.safari_9_10;
|
2018-07-30 16:06:08 +00:00
|
|
|
} else if ( /firefox\/(?:52|60)/i.test( userAgent ) ) {
|
2018-07-09 16:37:52 +00:00
|
|
|
expected = expectedMap.firefox_60;
|
2014-12-09 20:05:31 +00:00
|
|
|
} else if ( /firefox/i.test( userAgent ) ) {
|
2018-04-23 12:16:21 +00:00
|
|
|
expected = expectedMap.firefox;
|
2019-09-23 18:00:24 +00:00
|
|
|
} else if ( /android 4\.[0-3]/i.test( userAgent ) ) {
|
|
|
|
expected = expectedMap.android;
|
2016-09-19 16:55:12 +00:00
|
|
|
} else if ( /iphone os (?:9|10)_/i.test( userAgent ) ) {
|
2018-04-23 12:16:21 +00:00
|
|
|
expected = expectedMap.ios_9_10;
|
2015-10-30 18:16:27 +00:00
|
|
|
} else if ( /iphone os 8_/i.test( userAgent ) ) {
|
2018-04-23 12:16:21 +00:00
|
|
|
expected = expectedMap.ios_8;
|
2015-10-30 18:16:27 +00:00
|
|
|
} else if ( /iphone os 7_/i.test( userAgent ) ) {
|
2018-04-23 12:16:21 +00:00
|
|
|
expected = expectedMap.ios_7;
|
2019-09-23 17:28:43 +00:00
|
|
|
} else if ( /(?:iphone|ipad);.*(?:iphone)? os \d+_/i.test( userAgent ) ) {
|
|
|
|
expected = expectedMap.ios;
|
2019-09-23 18:00:24 +00:00
|
|
|
} else if ( /\b\d+(\.\d+)+ safari/i.test( userAgent ) ) {
|
|
|
|
expected = expectedMap.safari;
|
2013-03-07 14:15:12 +00:00
|
|
|
}
|
|
|
|
|
2015-05-08 03:16:18 +00:00
|
|
|
QUnit.test( "Verify that support tests resolve as expected per browser", function( assert ) {
|
|
|
|
if ( !expected ) {
|
|
|
|
assert.expect( 1 );
|
|
|
|
assert.ok( false, "Known client: " + userAgent );
|
|
|
|
}
|
2013-03-07 14:15:12 +00:00
|
|
|
|
2015-05-08 03:16:18 +00:00
|
|
|
var i, prop,
|
|
|
|
j = 0;
|
2013-03-07 14:15:12 +00:00
|
|
|
|
2015-05-08 03:16:18 +00:00
|
|
|
for ( prop in computedSupport ) {
|
|
|
|
j++;
|
|
|
|
}
|
2013-03-07 14:15:12 +00:00
|
|
|
|
2015-05-08 03:16:18 +00:00
|
|
|
assert.expect( j );
|
2015-08-16 06:59:58 +00:00
|
|
|
|
2015-05-08 03:16:18 +00:00
|
|
|
for ( i in expected ) {
|
|
|
|
if ( jQuery.ajax || i !== "ajax" && i !== "cors" ) {
|
|
|
|
assert.equal( computedSupport[ i ], expected[ i ],
|
|
|
|
"jQuery.support['" + i + "']: " + computedSupport[ i ] +
|
|
|
|
", expected['" + i + "']: " + expected[ i ] );
|
|
|
|
} else {
|
|
|
|
assert.ok( true, "no ajax; skipping jQuery.support['" + i + "']" );
|
2013-03-07 14:15:12 +00:00
|
|
|
}
|
2015-05-08 03:16:18 +00:00
|
|
|
}
|
2016-01-27 11:13:32 +00:00
|
|
|
} );
|
2013-03-07 14:15:12 +00:00
|
|
|
|
2018-04-23 12:16:21 +00:00
|
|
|
QUnit.test( "Verify most support tests are failing in one " +
|
|
|
|
"of tested browsers", function( assert ) {
|
|
|
|
|
|
|
|
var prop, browserKey, supportTestName,
|
|
|
|
i = 0,
|
|
|
|
supportProps = {},
|
|
|
|
failingSupportProps = {},
|
|
|
|
whitelist = {
|
|
|
|
ajax: true
|
|
|
|
};
|
|
|
|
|
|
|
|
for ( prop in computedSupport ) {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.expect( i );
|
|
|
|
|
|
|
|
// Record all support props and the failing ones and ensure everyone
|
|
|
|
// except a few on a whitelist are failing at least once.
|
|
|
|
for ( browserKey in expectedMap ) {
|
|
|
|
for ( supportTestName in expectedMap[ browserKey ] ) {
|
|
|
|
supportProps[ supportTestName ] = true;
|
|
|
|
if ( expectedMap[ browserKey ][ supportTestName ] !== true ) {
|
|
|
|
failingSupportProps[ supportTestName ] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( supportTestName in supportProps ) {
|
|
|
|
assert.ok( whitelist[ supportTestName ] || failingSupportProps[ supportTestName ],
|
|
|
|
"jQuery.support['" + supportTestName + "'] always succeeds; remove it?" );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
} )();
|