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
|
2019-04-29 20:56:09 +00:00
|
|
|
// i.e. no IE
|
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 = {
|
2019-08-19 16:41:03 +00:00
|
|
|
edge: {
|
2019-10-14 16:41:35 +00:00
|
|
|
reliableTrDimensions: false,
|
2019-08-19 16:41:03 +00:00
|
|
|
scope: undefined
|
|
|
|
},
|
|
|
|
ie_11: {
|
2019-10-14 16:41:35 +00:00
|
|
|
reliableTrDimensions: false,
|
2019-08-19 16:41:03 +00:00
|
|
|
scope: undefined
|
|
|
|
},
|
|
|
|
chrome: {
|
2019-10-14 16:41:35 +00:00
|
|
|
reliableTrDimensions: true,
|
2019-08-19 16:41:03 +00:00
|
|
|
scope: true
|
|
|
|
},
|
|
|
|
safari: {
|
2019-10-14 16:41:35 +00:00
|
|
|
reliableTrDimensions: true,
|
2019-08-19 16:41:03 +00:00
|
|
|
scope: true
|
|
|
|
},
|
|
|
|
firefox: {
|
2019-10-14 16:41:35 +00:00
|
|
|
reliableTrDimensions: true,
|
2019-08-19 16:41:03 +00:00
|
|
|
scope: true
|
|
|
|
},
|
|
|
|
ios: {
|
2019-10-14 16:41:35 +00:00
|
|
|
reliableTrDimensions: true,
|
2019-08-19 16:41:03 +00:00
|
|
|
scope: true
|
|
|
|
}
|
2018-04-23 12:16:21 +00:00
|
|
|
};
|
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;
|
2019-04-29 20:56:09 +00:00
|
|
|
} else if ( document.documentMode ) {
|
|
|
|
expected = expectedMap.ie_11;
|
2015-06-13 22:50:05 +00:00
|
|
|
} else if ( /chrome/i.test( userAgent ) ) {
|
2015-08-16 06:59:58 +00:00
|
|
|
|
2019-04-29 20:56:09 +00:00
|
|
|
// Catches Chrome on Android & Opera as well.
|
2018-04-23 12:16:21 +00:00
|
|
|
expected = expectedMap.chrome;
|
2019-04-29 20:56:09 +00:00
|
|
|
} else if ( /\b\d+(\.\d+)+ safari/i.test( userAgent ) ) {
|
2018-11-12 17:55:47 +00:00
|
|
|
expected = expectedMap.safari;
|
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-04-29 20:56:09 +00:00
|
|
|
} else if ( /(?:iphone|ipad);.*(?:iphone)? os \d+_/i.test( userAgent ) ) {
|
2018-11-12 17:55:47 +00:00
|
|
|
expected = expectedMap.ios;
|
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
|
|
|
|
2019-08-19 16:41:03 +00:00
|
|
|
// Add an assertion per undefined support prop as it may
|
|
|
|
// not even exist on computedSupport but we still want to run
|
|
|
|
// the check.
|
|
|
|
for ( prop in expected ) {
|
|
|
|
if ( expected[ prop ] === undefined ) {
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 ) {
|
2019-04-29 20:56:09 +00:00
|
|
|
assert.equal( computedSupport[ i ], expected[ i ],
|
|
|
|
"jQuery.support['" + i + "']: " + computedSupport[ i ] +
|
|
|
|
", expected['" + i + "']: " + expected[ i ] );
|
2015-05-08 03:16:18 +00:00
|
|
|
}
|
2016-01-27 11:13:32 +00:00
|
|
|
} );
|
2013-03-07 14:15:12 +00:00
|
|
|
|
2019-05-13 19:39:56 +00:00
|
|
|
QUnit.test( "Verify support tests are failing in one of tested browsers",
|
|
|
|
function( assert ) {
|
2018-04-23 12:16:21 +00:00
|
|
|
|
|
|
|
var prop, browserKey, supportTestName,
|
|
|
|
i = 0,
|
|
|
|
supportProps = {},
|
2019-04-29 20:56:09 +00:00
|
|
|
failingSupportProps = {};
|
2018-04-23 12:16:21 +00:00
|
|
|
|
|
|
|
for ( prop in computedSupport ) {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2019-08-19 16:41:03 +00:00
|
|
|
// Add an assertion per undefined support prop as it may
|
|
|
|
// not even exist on computedSupport but we still want to run
|
|
|
|
// the check.
|
|
|
|
for ( prop in expected ) {
|
|
|
|
if ( expected[ prop ] === undefined ) {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-23 12:16:21 +00:00
|
|
|
assert.expect( i );
|
|
|
|
|
2019-04-29 20:56:09 +00:00
|
|
|
// Record all support props and the failing ones and ensure every test
|
|
|
|
// is failing at least once.
|
2018-04-23 12:16:21 +00:00
|
|
|
for ( browserKey in expectedMap ) {
|
|
|
|
for ( supportTestName in expectedMap[ browserKey ] ) {
|
|
|
|
supportProps[ supportTestName ] = true;
|
2019-08-19 16:41:03 +00:00
|
|
|
if ( !expectedMap[ browserKey ][ supportTestName ] ) {
|
2018-04-23 12:16:21 +00:00
|
|
|
failingSupportProps[ supportTestName ] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( supportTestName in supportProps ) {
|
2019-04-29 20:56:09 +00:00
|
|
|
assert.ok( failingSupportProps[ supportTestName ],
|
|
|
|
"jQuery.support['" + supportTestName +
|
|
|
|
"'] is expected to fail at least in one browser" );
|
2018-04-23 12:16:21 +00:00
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
} )();
|