3 if ( !jQuery.fn.width ) {
7 QUnit.module( "dimensions", { teardown: moduleTeardown } );
20 ======== local reference =======
21 pass and fn can be used to test passing functions to setters
22 See testWidth below for an example
24 pass( value, assert );
25 This function returns whatever value is passed in
28 Returns a function that returns the value
31 function testWidth( val, assert ) {
35 $div = jQuery( "#nothiddendiv" );
36 $div.width( val( 30 ) );
37 assert.equal( $div.width(), 30, "Test set to 30 correctly" );
38 $div.css( "display", "none" );
39 assert.equal( $div.width(), 30, "Test hidden div" );
40 $div.css( "display", "" );
41 $div.width( val( -1 ) ); // handle negative numbers by setting to 0 #11604
42 assert.equal( $div.width(), 0, "Test negative width normalized to 0" );
43 $div.css( "padding", "20px" );
44 assert.equal( $div.width(), 0, "Test padding specified with pixels" );
45 $div.css( "border", "2px solid #fff" );
46 assert.equal( $div.width(), 0, "Test border specified with pixels" );
48 $div.css( { "display": "", "border": "", "padding": "" } );
50 jQuery( "#nothiddendivchild" ).css( { "width": 20, "padding": "3px", "border": "2px solid #fff" } );
51 assert.equal( jQuery( "#nothiddendivchild" ).width(), 20, "Test child width with border and padding" );
52 jQuery( "#nothiddendiv, #nothiddendivchild" ).css( { "border": "", "padding": "", "width": "" } );
55 assert.equal( $empty.width( val( 10 ) ), $empty, "Make sure that setting a width on an empty set returns the set." );
56 assert.strictEqual( $empty.width(), undefined, "Make sure 'undefined' is returned on an empty set" );
58 assert.equal( jQuery( window ).width(), document.documentElement.clientWidth, "Window width is equal to width reported by window/document." );
61 QUnit.test( "width()", function( assert ) {
62 testWidth( pass, assert );
65 QUnit.test( "width(Function)", function( assert ) {
66 testWidth( fn, assert );
69 QUnit.test( "width(Function(args))", function( assert ) {
72 var $div = jQuery( "#nothiddendiv" );
73 $div.width( 30 ).width( function( i, width ) {
74 assert.equal( width, 30, "Make sure previous value is correct." );
78 assert.equal( $div.width(), 31, "Make sure value was modified correctly." );
81 function testHeight( val, assert ) {
86 $div = jQuery( "#nothiddendiv" );
87 $div.height( val( 30 ) );
88 assert.equal( $div.height(), 30, "Test set to 30 correctly" );
89 $div.css( "display", "none" );
90 assert.equal( $div.height(), 30, "Test hidden div" );
91 $div.css( "display", "" );
92 $div.height( val( -1 ) ); // handle negative numbers by setting to 0 #11604
93 assert.equal( $div.height(), 0, "Test negative height normalized to 0" );
94 $div.css( "padding", "20px" );
95 assert.equal( $div.height(), 0, "Test padding specified with pixels" );
96 $div.css( "border", "2px solid #fff" );
97 assert.equal( $div.height(), 0, "Test border specified with pixels" );
99 $div.css( { "display": "", "border": "", "padding": "", "height": "1px" } );
101 jQuery( "#nothiddendivchild" ).css( { "height": 20, "padding": "3px", "border": "2px solid #fff" } );
102 assert.equal( jQuery( "#nothiddendivchild" ).height(), 20, "Test child height with border and padding" );
103 jQuery( "#nothiddendiv, #nothiddendivchild" ).css( { "border": "", "padding": "", "height": "" } );
105 blah = jQuery( "blah" );
106 assert.equal( blah.height( val( 10 ) ), blah, "Make sure that setting a height on an empty set returns the set." );
107 assert.strictEqual( blah.height(), undefined, "Make sure 'undefined' is returned on an empty set" );
109 assert.equal( jQuery( window ).height(), document.documentElement.clientHeight, "Window width is equal to width reported by window/document." );
112 QUnit.test( "height()", function( assert ) {
113 testHeight( pass, assert );
116 QUnit.test( "height(Function)", function( assert ) {
117 testHeight( fn, assert );
120 QUnit.test( "height(Function(args))", function( assert ) {
123 var $div = jQuery( "#nothiddendiv" );
124 $div.height( 30 ).height( function( i, height ) {
125 assert.equal( height, 30, "Make sure previous value is correct." );
129 assert.equal( $div.height(), 31, "Make sure value was modified correctly." );
132 QUnit.test( "innerWidth()", function( assert ) {
136 $win = jQuery( window ),
137 $doc = jQuery( document );
139 assert.equal( jQuery( window ).innerWidth(), $win.width(), "Test on window" );
140 assert.equal( jQuery( document ).innerWidth(), $doc.width(), "Test on document" );
141 assert.strictEqual( jQuery().innerWidth(), undefined, "Test on empty set" );
143 $div = jQuery( "#nothiddendiv" );
146 "border": "2px solid #fff",
150 assert.equal( $div.innerWidth(), 30, "Test with margin and border" );
151 $div.css( "padding", "20px" );
152 assert.equal( $div.innerWidth(), 70, "Test with margin, border and padding" );
153 $div.css( "display", "none" );
154 assert.equal( $div.innerWidth(), 70, "Test hidden div" );
157 $div.css( { "display": "", "border": "", "padding": "", "width": "", "height": "" } );
159 div = jQuery( "<div>" );
161 // Temporarily require 0 for backwards compat - should be auto
162 assert.equal( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
167 QUnit.test( "innerHeight()", function( assert ) {
171 $win = jQuery( window ),
172 $doc = jQuery( document );
174 assert.equal( jQuery( window ).innerHeight(), $win.height(), "Test on window" );
175 assert.equal( jQuery( document ).innerHeight(), $doc.height(), "Test on document" );
176 assert.strictEqual( jQuery().innerHeight(), undefined, "Test on empty set" );
178 $div = jQuery( "#nothiddendiv" );
181 "border": "2px solid #fff",
185 assert.equal( $div.innerHeight(), 30, "Test with margin and border" );
186 $div.css( "padding", "20px" );
187 assert.equal( $div.innerHeight(), 70, "Test with margin, border and padding" );
188 $div.css( "display", "none" );
189 assert.equal( $div.innerHeight(), 70, "Test hidden div" );
192 $div.css( { "display": "", "border": "", "padding": "", "width": "", "height": "" } );
194 div = jQuery( "<div>" );
196 // Temporarily require 0 for backwards compat - should be auto
197 assert.equal( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
202 QUnit.test( "outerWidth()", function( assert ) {
206 $win = jQuery( window ),
207 $doc = jQuery( document ),
208 winwidth = $win.prop( "innerWidth" );
210 assert.equal( jQuery( window ).outerWidth(), winwidth, "Test on window without margin option" );
211 assert.equal( jQuery( window ).outerWidth( true ), winwidth, "Test on window with margin option" );
212 assert.equal( jQuery( document ).outerWidth(), $doc.width(), "Test on document without margin option" );
213 assert.equal( jQuery( document ).outerWidth( true ), $doc.width(), "Test on document with margin option" );
214 assert.strictEqual( jQuery().outerWidth(), undefined, "Test on empty set" );
216 $div = jQuery( "#nothiddendiv" );
217 $div.css( "width", 30 );
219 assert.equal( $div.outerWidth(), 30, "Test with only width set" );
220 $div.css( "padding", "20px" );
221 assert.equal( $div.outerWidth(), 70, "Test with padding" );
222 $div.css( "border", "2px solid #fff" );
223 assert.equal( $div.outerWidth(), 74, "Test with padding and border" );
224 $div.css( "margin", "10px" );
225 assert.equal( $div.outerWidth(), 74, "Test with padding, border and margin without margin option" );
226 $div.css( "position", "absolute" );
227 assert.equal( $div.outerWidth( true ), 94, "Test with padding, border and margin with margin option" );
228 $div.css( "display", "none" );
229 assert.equal( $div.outerWidth( true ), 94, "Test hidden div with padding, border and margin with margin option" );
232 $div.css( { "position": "", "display": "", "border": "", "padding": "", "width": "", "height": "" } );
234 div = jQuery( "<div>" );
236 // Temporarily require 0 for backwards compat - should be auto
237 assert.equal( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
242 QUnit.test( "outerHeight()", function( assert ) {
246 $win = jQuery( window ),
247 $doc = jQuery( document ),
248 winheight = $win.prop( "innerHeight" );
250 assert.equal( jQuery( window ).outerHeight(), winheight, "Test on window without margin option" );
251 assert.equal( jQuery( window ).outerHeight( true ), winheight, "Test on window with margin option" );
252 assert.equal( jQuery( document ).outerHeight(), $doc.height(), "Test on document without margin option" );
253 assert.equal( jQuery( document ).outerHeight( true ), $doc.height(), "Test on document with margin option" );
254 assert.strictEqual( jQuery().outerHeight(), undefined, "Test on empty set" );
256 $div = jQuery( "#nothiddendiv" );
257 $div.css( "height", 30 );
259 assert.equal( $div.outerHeight(), 30, "Test with only height set" );
260 $div.css( "padding", "20px" );
261 assert.equal( $div.outerHeight(), 70, "Test with padding" );
262 $div.css( "border", "2px solid #fff" );
263 assert.equal( $div.outerHeight(), 74, "Test with padding and border" );
264 $div.css( "margin", "10px" );
265 assert.equal( $div.outerHeight(), 74, "Test with padding, border and margin without margin option" );
266 $div.css( "position", "absolute" );
267 assert.equal( $div.outerHeight( true ), 94, "Test with padding, border and margin with margin option" );
268 $div.css( "display", "none" );
269 assert.equal( $div.outerHeight( true ), 94, "Test hidden div with padding, border and margin with margin option" );
272 $div.css( { "position": "", "display": "", "border": "", "padding": "", "width": "", "height": "" } );
274 div = jQuery( "<div>" );
276 // Temporarily require 0 for backwards compat - should be auto
277 assert.equal( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
282 QUnit.test( "child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #9441 #9300", function( assert ) {
286 var $divNormal = jQuery( "<div>" ).css( { "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" } ),
287 $divChild = $divNormal.clone(),
288 $divUnconnected = $divNormal.clone(),
289 $divHiddenParent = jQuery( "<div>" ).css( "display", "none" ).append( $divChild ).appendTo( "body" );
290 $divNormal.appendTo( "body" );
292 // tests that child div of a hidden div works the same as a normal div
293 assert.equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #9441" );
294 assert.equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #9441" );
295 assert.equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #9441" );
296 assert.equal( $divChild.outerWidth( true ), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #9300" );
298 // Support: IE 10-11, Edge
299 // Child height is not always decimal
300 assert.equal( $divChild.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "child of a hidden element height() is wrong see #9441" );
301 assert.equal( $divChild.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "child of a hidden element innerHeight() is wrong see #9441" );
302 assert.equal( $divChild.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "child of a hidden element outerHeight() is wrong see #9441" );
303 assert.equal( $divChild.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "child of a hidden element outerHeight( true ) is wrong see #9300" );
305 // tests that child div of an unconnected div works the same as a normal div
306 assert.equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #9441" );
307 assert.equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #9441" );
308 assert.equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #9441" );
309 assert.equal( $divUnconnected.outerWidth( true ), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #9300" );
311 // Support: IE 10-11, Edge
312 // Child height is not always decimal
313 assert.equal( $divUnconnected.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "unconnected element height() is wrong see #9441" );
314 assert.equal( $divUnconnected.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "unconnected element innerHeight() is wrong see #9441" );
315 assert.equal( $divUnconnected.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "unconnected element outerHeight() is wrong see #9441" );
316 assert.equal( $divUnconnected.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "unconnected element outerHeight( true ) is wrong see #9300" );
319 $divHiddenParent.remove();
323 QUnit.test( "getting dimensions shouldn't modify runtimeStyle see #9233", function( assert ) {
326 var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ),
328 runtimeStyle = div.runtimeStyle;
330 if ( runtimeStyle ) {
331 div.runtimeStyle.marginLeft = "12em";
332 div.runtimeStyle.left = "11em";
335 $div.outerWidth( true );
337 if ( runtimeStyle ) {
338 assert.equal( div.runtimeStyle.left, "11em", "getting dimensions modifies runtimeStyle, see #9233" );
340 assert.ok( true, "this browser doesn't support runtimeStyle, see #9233" );
346 QUnit.test( "table dimensions", function( assert ) {
349 var table = jQuery( "<table><colgroup><col/><col/></colgroup><tbody><tr><td></td><td>a</td></tr><tr><td></td><td>a</td></tr></tbody></table>" ).appendTo( "#qunit-fixture" ),
350 tdElem = table.find( "td" ).first(),
351 colElem = table.find( "col" ).first().width( 300 );
353 table.find( "td" ).css( { "margin": 0, "padding": 0 } );
355 assert.equal( tdElem.width(), tdElem.width(), "width() doesn't alter dimension values of empty cells, see #11293" );
356 assert.equal( colElem.width(), 300, "col elements have width(), see #12243" );
359 QUnit.test( "box-sizing:border-box child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #10413", function( assert ) {
363 var $divNormal = jQuery( "<div>" ).css( { "boxSizing": "border-box", "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" } ),
364 $divChild = $divNormal.clone(),
365 $divUnconnected = $divNormal.clone(),
366 $divHiddenParent = jQuery( "<div>" ).css( "display", "none" ).append( $divChild ).appendTo( "body" );
367 $divNormal.appendTo( "body" );
369 // tests that child div of a hidden div works the same as a normal div
370 assert.equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #10413" );
371 assert.equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #10413" );
372 assert.equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #10413" );
373 assert.equal( $divChild.outerWidth( true ), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #10413" );
375 // Support: IE 10-11, Edge
376 // Child height is not always decimal
377 assert.equal( $divChild.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "child of a hidden element height() is wrong see #10413" );
378 assert.equal( $divChild.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "child of a hidden element innerHeight() is wrong see #10413" );
379 assert.equal( $divChild.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "child of a hidden element outerHeight() is wrong see #10413" );
380 assert.equal( $divChild.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "child of a hidden element outerHeight( true ) is wrong see #10413" );
382 // tests that child div of an unconnected div works the same as a normal div
383 assert.equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #10413" );
384 assert.equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #10413" );
385 assert.equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #10413" );
386 assert.equal( $divUnconnected.outerWidth( true ), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #10413" );
388 // Support: IE 10-11, Edge
389 // Child height is not always decimal
390 assert.equal( $divUnconnected.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "unconnected element height() is wrong see #10413" );
391 assert.equal( $divUnconnected.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "unconnected element innerHeight() is wrong see #10413" );
392 assert.equal( $divUnconnected.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "unconnected element outerHeight() is wrong see #10413" );
393 assert.equal( $divUnconnected.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "unconnected element outerHeight( true ) is wrong see #10413" );
396 $divHiddenParent.remove();
400 QUnit.test( "passing undefined is a setter #5571", function( assert ) {
402 assert.equal( jQuery( "#nothiddendiv" ).height( 30 ).height( undefined ).height(), 30, ".height(undefined) is chainable (#5571)" );
403 assert.equal( jQuery( "#nothiddendiv" ).height( 30 ).innerHeight( undefined ).height(), 30, ".innerHeight(undefined) is chainable (#5571)" );
404 assert.equal( jQuery( "#nothiddendiv" ).height( 30 ).outerHeight( undefined ).height(), 30, ".outerHeight(undefined) is chainable (#5571)" );
405 assert.equal( jQuery( "#nothiddendiv" ).width( 30 ).width( undefined ).width(), 30, ".width(undefined) is chainable (#5571)" );
408 QUnit.test( "setters with and without box-sizing:border-box", function( assert ) {
409 assert.expect( 120 );
411 var parent = jQuery( "#foo" ).css({ width: "200px", height: "200px", "font-size": "16px" }),
412 el_bb = jQuery( "<div style='margin:5px;padding:1px;border:2px solid black;box-sizing:border-box;'></div>" ).appendTo( parent ),
413 el = jQuery( "<div style='margin:5px;padding:1px;border:2px solid black;'></div>" ).appendTo( parent ),
414 el_bb_np = jQuery( "<div style='margin:5px; padding:0px; border:0px solid green;box-sizing:border-box;'></div>" ).appendTo( parent ),
415 el_np = jQuery( "<div style='margin:5px; padding:0px; border:0px solid green;'></div>" ).appendTo( parent );
418 "number": { set: 100, expected: 100 },
419 "em": { set: "10em", expected: 160 },
420 "percentage": { set: "50%", expected: 100 }
421 }, function( units, values ) {
422 assert.equal( el_bb.width( values.set ).width(), values.expected, "test border-box width(" + units + ") by roundtripping" );
423 assert.equal( el_bb.innerWidth( values.set ).width(), values.expected - 2, "test border-box innerWidth(" + units + ") by roundtripping" );
424 assert.equal( el_bb.outerWidth( values.set ).width(), values.expected - 6, "test border-box outerWidth(" + units + ") by roundtripping" );
425 assert.equal( el_bb.outerWidth( values.set, false ).width(), values.expected - 6, "test border-box outerWidth(" + units + ", false) by roundtripping" );
426 assert.equal( el_bb.outerWidth( values.set, true ).width(), values.expected - 16, "test border-box outerWidth(" + units + ", true) by roundtripping" );
428 assert.equal( el_bb.height( values.set ).height(), values.expected, "test border-box height(" + units + ") by roundtripping" );
429 assert.equal( el_bb.innerHeight( values.set ).height(), values.expected - 2, "test border-box innerHeight(" + units + ") by roundtripping" );
430 assert.equal( el_bb.outerHeight( values.set ).height(), values.expected - 6, "test border-box outerHeight(" + units + ") by roundtripping" );
431 assert.equal( el_bb.outerHeight( values.set, false ).height(), values.expected - 6, "test border-box outerHeight(" + units + ", false) by roundtripping" );
432 assert.equal( el_bb.outerHeight( values.set, true ).height(), values.expected - 16, "test border-box outerHeight(" + units + ", true) by roundtripping" );
434 assert.equal( el.width( values.set ).width(), values.expected, "test non-border-box width(" + units + ") by roundtripping" );
435 assert.equal( el.innerWidth( values.set ).width(), values.expected - 2, "test non-border-box innerWidth(" + units + ") by roundtripping" );
436 assert.equal( el.outerWidth( values.set ).width(), values.expected - 6, "test non-border-box outerWidth(" + units + ") by roundtripping" );
437 assert.equal( el.outerWidth( values.set, false ).width(), values.expected - 6, "test non-border-box outerWidth(" + units + ", false) by roundtripping" );
438 assert.equal( el.outerWidth( values.set, true ).width(), values.expected - 16, "test non-border-box outerWidth(" + units + ", true) by roundtripping" );
440 assert.equal( el.height( values.set ).height(), values.expected, "test non-border-box height(" + units + ") by roundtripping" );
441 assert.equal( el.innerHeight( values.set ).height(), values.expected - 2, "test non-border-box innerHeight(" + units + ") by roundtripping" );
442 assert.equal( el.outerHeight( values.set ).height(), values.expected - 6, "test non-border-box outerHeight(" + units + ") by roundtripping" );
443 assert.equal( el.outerHeight( values.set, false ).height(), values.expected - 6, "test non-border-box outerHeight(" + units + ", false) by roundtripping" );
444 assert.equal( el.outerHeight( values.set, true ).height(), values.expected - 16, "test non-border-box outerHeight(" + units + ", true) by roundtripping" );
446 assert.equal( el_bb_np.width( values.set ).width(), values.expected, "test border-box width and negative padding(" + units + ") by roundtripping" );
447 assert.equal( el_bb_np.innerWidth( values.set ).width(), values.expected, "test border-box innerWidth and negative padding(" + units + ") by roundtripping" );
448 assert.equal( el_bb_np.outerWidth( values.set ).width(), values.expected, "test border-box outerWidth and negative padding(" + units + ") by roundtripping" );
449 assert.equal( el_bb_np.outerWidth( values.set, false ).width(), values.expected, "test border-box outerWidth and negative padding(" + units + ", false) by roundtripping" );
450 assert.equal( el_bb_np.outerWidth( values.set, true ).width(), values.expected - 10, "test border-box outerWidth and negative padding(" + units + ", true) by roundtripping" );
452 assert.equal( el_bb_np.height( values.set ).height(), values.expected, "test border-box height and negative padding(" + units + ") by roundtripping" );
453 assert.equal( el_bb_np.innerHeight( values.set ).height(), values.expected, "test border-box innerHeight and negative padding(" + units + ") by roundtripping" );
454 assert.equal( el_bb_np.outerHeight( values.set ).height(), values.expected, "test border-box outerHeight and negative padding(" + units + ") by roundtripping" );
455 assert.equal( el_bb_np.outerHeight( values.set, false ).height(), values.expected, "test border-box outerHeight and negative padding(" + units + ", false) by roundtripping" );
456 assert.equal( el_bb_np.outerHeight( values.set, true ).height(), values.expected - 10, "test border-box outerHeight and negative padding(" + units + ", true) by roundtripping" );
458 assert.equal( el_np.width( values.set ).width(), values.expected, "test non-border-box width and negative padding(" + units + ") by roundtripping" );
459 assert.equal( el_np.innerWidth( values.set ).width(), values.expected, "test non-border-box innerWidth and negative padding(" + units + ") by roundtripping" );
460 assert.equal( el_np.outerWidth( values.set ).width(), values.expected, "test non-border-box outerWidth and negative padding(" + units + ") by roundtripping" );
461 assert.equal( el_np.outerWidth( values.set, false ).width(), values.expected, "test non-border-box outerWidth and negative padding(" + units + ", false) by roundtripping" );
462 assert.equal( el_np.outerWidth( values.set, true ).width(), values.expected - 10, "test non-border-box outerWidth and negative padding(" + units + ", true) by roundtripping" );
464 assert.equal( el_np.height( values.set ).height(), values.expected, "test non-border-box height and negative padding(" + units + ") by roundtripping" );
465 assert.equal( el_np.innerHeight( values.set ).height(), values.expected, "test non-border-box innerHeight and negative padding(" + units + ") by roundtripping" );
466 assert.equal( el_np.outerHeight( values.set ).height(), values.expected, "test non-border-box outerHeight and negative padding(" + units + ") by roundtripping" );
467 assert.equal( el_np.outerHeight( values.set, false ).height(), values.expected, "test non-border-box outerHeight and negative padding(" + units + ", false) by roundtripping" );
468 assert.equal( el_np.outerHeight( values.set, true ).height(), values.expected - 10, "test non-border-box outerHeight and negative padding(" + units + ", true) by roundtripping" );
473 "dimensions/documentLarge",
474 "window vs. large document",
475 function( jQuery, window, document, assert ) {
478 assert.ok( jQuery( document ).height() > jQuery( window ).height(), "document height is larger than window height" );
479 assert.ok( jQuery( document ).width() > jQuery( window ).width(), "document width is larger than window width" );
483 QUnit.test( "allow modification of coordinates argument (gh-1848)", function( assert ) {
487 element = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );
489 element.offset( function( index, coords ) {
495 offsetTop = element.offset().top;
496 assert.ok( Math.abs( offsetTop - 100 ) < 0.02,
497 "coordinates are modified (got offset.top: " + offsetTop + ")" );
500 QUnit.test( "outside view position (gh-2836)", function( assert ) {
502 // This test ported from gh-2836 example
507 "<div id=div-gh-2836>",
515 stop = assert.async();
517 parent = jQuery( html );
518 parent.appendTo( "#qunit-fixture" );
520 parent.one( "scroll", function() {
521 var pos = parent.find( "div" ).eq( 3 ).position();
523 assert.strictEqual(pos.top, -100);
527 parent.scrollTop( 400 );