2
Respond.js unit tests - based on qUnit
5
window.onload = function(){
9
document.documentElement.className = "launcher";
11
document.getElementById("launcher").innerHTML = '<p>Tests must run in a popup window. <a href="suite.html" id="suitelink">Open test suite</a></p>';
13
document.getElementById( "suitelink" ).onclick = function(){
14
window.open( location.href + "?" + Math.random(), 'win', 'width=800,height=600,scrollbars=1,resizable=1' );
21
var testElem = document.getElementById("testelem");
23
//check if a particular style has applied properly
24
function widthApplied( val ){
25
return testElem.offsetWidth === val;
27
function heightApplied( val ){
28
return testElem.offsetHeight === val;
31
// A short snippet for detecting versions of IE in JavaScript - author: @padolsey
36
div = document.createElement('div'),
37
all = div.getElementsByTagName('i');
40
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
44
return v > 4 ? v : undef;
51
asyncTest( 'Styles not nested in media queries apply as expected', function() {
52
window.resizeTo(200,600);
53
setTimeout(function(){
54
ok( widthApplied( 50 ), "testelem is 50px wide when window is 200px wide" );
59
asyncTest( 'styles within min-width media queries apply properly', function() {
60
window.resizeTo(520,600);
61
setTimeout(function(){
62
ok( widthApplied( 150 ), 'testelem is 150px wide when window is 500px wide' );
67
// This test is for a feature in IE7 and up
69
asyncTest( "attribute selectors still work (where supported) after respond runs its course", function() {
70
window.resizeTo(520,600);
71
setTimeout(function(){
72
ok( heightApplied( 200 ), "testelem is 200px tall when window is 500px wide" );
79
asyncTest( 'styles within max-width media queries apply properly', function() {
80
window.resizeTo(300,600);
81
setTimeout(function(){
82
ok( heightApplied( 150 ), 'testelem is 150px tall when window is under 480px wide' );
89
asyncTest( 'min and max-width media queries that use EM units apply properly', function() {
90
window.resizeTo(560,600);
91
setTimeout(function(){
92
ok( widthApplied( 12 ), 'testelem is 150px wide when window is 500px wide' );
99
asyncTest( "styles within a min-width media query with an \"only\" keyword apply properly", function() {
100
window.resizeTo(650,600);
101
setTimeout(function(){
102
ok( widthApplied( 250 ), "testelem is 250px wide when window is 650px wide" );
107
asyncTest( "styles within a media query with a one true query among other false queries apply properly", function() {
108
window.resizeTo(800,600);
109
setTimeout(function(){
110
ok( widthApplied( 350 ), "testelem is 350px wide when window is 750px wide" );
117
asyncTest( "Styles within a false media query do not apply", function() {
118
window.resizeTo(800,600);
119
setTimeout(function(){
120
ok( !widthApplied( 500 ), "testelem is not 500px wide when window is 800px wide" );
126
asyncTest( "stylesheets with a media query in a media attribute apply when they should", function() {
127
window.resizeTo(1300,600);
128
setTimeout(function(){
129
ok( widthApplied( 16 ), "testelem is 16px wide when window is 1300px wide" );
134
asyncTest( "stylesheets with an EM-based media query in a media attribute apply when they should", function() {
135
window.resizeTo(1500,600);
136
setTimeout(function(){
137
ok( widthApplied( 25 ), "testelem is 25px wide when window is > 1400px wide" );
b'\\ No newline at end of file'