Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / jquery / resources / test / unit / dimensions.js
blobfa59a9f77b578f035b070c57b0daf57e34e8f3e0
1 module("dimensions", { teardown: moduleTeardown });
3 function pass( val ) {
4 return val;
7 function fn( val ) {
8 return function(){ return val; };
11 function testWidth( val ) {
12 expect(8);
14 var $div = jQuery("#nothiddendiv");
15 $div.width( val(30) );
16 equals($div.width(), 30, "Test set to 30 correctly");
17 $div.hide();
18 equals($div.width(), 30, "Test hidden div");
19 $div.show();
20 $div.width( val(-1) ); // handle negative numbers by ignoring #1599
21 equals($div.width(), 30, "Test negative width ignored");
22 $div.css("padding", "20px");
23 equals($div.width(), 30, "Test padding specified with pixels");
24 $div.css("border", "2px solid #fff");
25 equals($div.width(), 30, "Test border specified with pixels");
27 $div.css({ display: "", border: "", padding: "" });
29 jQuery("#nothiddendivchild").css({ width: 20, padding: "3px", border: "2px solid #fff" });
30 equals(jQuery("#nothiddendivchild").width(), 20, "Test child width with border and padding");
31 jQuery("#nothiddendiv, #nothiddendivchild").css({ border: "", padding: "", width: "" });
33 var blah = jQuery("blah");
34 equals( blah.width( val(10) ), blah, "Make sure that setting a width on an empty set returns the set." );
35 equals( blah.width(), null, "Make sure 'null' is returned on an empty set");
37 jQuery.removeData($div[0], 'olddisplay', true);
40 test("width()", function() {
41 testWidth( pass );
42 });
44 test("width() with function", function() {
45 testWidth( fn );
46 });
48 test("width() with function args", function() {
49 expect( 2 );
51 var $div = jQuery("#nothiddendiv");
52 $div.width( 30 ).width(function(i, width) {
53 equals( width, 30, "Make sure previous value is corrrect." );
54 return width + 1;
55 });
57 equals( $div.width(), 31, "Make sure value was modified correctly." );
58 });
60 function testHeight( val ) {
61 expect(8);
63 var $div = jQuery("#nothiddendiv");
64 $div.height( val(30) );
65 equals($div.height(), 30, "Test set to 30 correctly");
66 $div.hide();
67 equals($div.height(), 30, "Test hidden div");
68 $div.show();
69 $div.height( val(-1) ); // handle negative numbers by ignoring #1599
70 equals($div.height(), 30, "Test negative height ignored");
71 $div.css("padding", "20px");
72 equals($div.height(), 30, "Test padding specified with pixels");
73 $div.css("border", "2px solid #fff");
74 equals($div.height(), 30, "Test border specified with pixels");
76 $div.css({ display: "", border: "", padding: "", height: "1px" });
78 jQuery("#nothiddendivchild").css({ height: 20, padding: "3px", border: "2px solid #fff" });
79 equals(jQuery("#nothiddendivchild").height(), 20, "Test child height with border and padding");
80 jQuery("#nothiddendiv, #nothiddendivchild").css({ border: "", padding: "", height: "" });
82 var blah = jQuery("blah");
83 equals( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
84 equals( blah.height(), null, "Make sure 'null' is returned on an empty set");
86 jQuery.removeData($div[0], 'olddisplay', true);
89 test("height()", function() {
90 testHeight( pass );
91 });
93 test("height() with function", function() {
94 testHeight( fn );
95 });
97 test("height() with function args", function() {
98 expect( 2 );
100 var $div = jQuery("#nothiddendiv");
101 $div.height( 30 ).height(function(i, height) {
102 equals( height, 30, "Make sure previous value is corrrect." );
103 return height + 1;
106 equals( $div.height(), 31, "Make sure value was modified correctly." );
109 test("innerWidth()", function() {
110 expect(4);
112 var $div = jQuery("#nothiddendiv");
113 // set styles
114 $div.css({
115 margin: 10,
116 border: "2px solid #fff",
117 width: 30
120 equals($div.innerWidth(), 30, "Test with margin and border");
121 $div.css("padding", "20px");
122 equals($div.innerWidth(), 70, "Test with margin, border and padding");
123 $div.hide();
124 equals($div.innerWidth(), 70, "Test hidden div");
126 // reset styles
127 $div.css({ display: "", border: "", padding: "", width: "", height: "" });
129 var div = jQuery( "<div>" );
131 // Temporarily require 0 for backwards compat - should be auto
132 equals( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
134 div.remove();
135 jQuery.removeData($div[0], 'olddisplay', true);
138 test("innerHeight()", function() {
139 expect(4);
141 var $div = jQuery("#nothiddendiv");
142 // set styles
143 $div.css({
144 margin: 10,
145 border: "2px solid #fff",
146 height: 30
149 equals($div.innerHeight(), 30, "Test with margin and border");
150 $div.css("padding", "20px");
151 equals($div.innerHeight(), 70, "Test with margin, border and padding");
152 $div.hide();
153 equals($div.innerHeight(), 70, "Test hidden div");
155 // reset styles
156 $div.css({ display: "", border: "", padding: "", width: "", height: "" });
158 var div = jQuery( "<div>" );
160 // Temporarily require 0 for backwards compat - should be auto
161 equals( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
163 div.remove();
164 jQuery.removeData($div[0], 'olddisplay', true);
167 test("outerWidth()", function() {
168 expect(7);
170 var $div = jQuery("#nothiddendiv");
171 $div.css("width", 30);
173 equals($div.outerWidth(), 30, "Test with only width set");
174 $div.css("padding", "20px");
175 equals($div.outerWidth(), 70, "Test with padding");
176 $div.css("border", "2px solid #fff");
177 equals($div.outerWidth(), 74, "Test with padding and border");
178 $div.css("margin", "10px");
179 equals($div.outerWidth(), 74, "Test with padding, border and margin without margin option");
180 $div.css("position", "absolute");
181 equals($div.outerWidth(true), 94, "Test with padding, border and margin with margin option");
182 $div.hide();
183 equals($div.outerWidth(true), 94, "Test hidden div with padding, border and margin with margin option");
185 // reset styles
186 $div.css({ position: "", display: "", border: "", padding: "", width: "", height: "" });
188 var div = jQuery( "<div>" );
190 // Temporarily require 0 for backwards compat - should be auto
191 equals( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
193 div.remove();
194 jQuery.removeData($div[0], 'olddisplay', true);
197 test("outerHeight()", function() {
198 expect(7);
200 var $div = jQuery("#nothiddendiv");
201 $div.css("height", 30);
203 equals($div.outerHeight(), 30, "Test with only width set");
204 $div.css("padding", "20px");
205 equals($div.outerHeight(), 70, "Test with padding");
206 $div.css("border", "2px solid #fff");
207 equals($div.outerHeight(), 74, "Test with padding and border");
208 $div.css("margin", "10px");
209 equals($div.outerHeight(), 74, "Test with padding, border and margin without margin option");
210 equals($div.outerHeight(true), 94, "Test with padding, border and margin with margin option");
211 $div.hide();
212 equals($div.outerHeight(true), 94, "Test hidden div with padding, border and margin with margin option");
214 // reset styles
215 $div.css({ display: "", border: "", padding: "", width: "", height: "" });
217 var div = jQuery( "<div>" );
219 // Temporarily require 0 for backwards compat - should be auto
220 equals( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
222 div.remove();
223 jQuery.removeData($div[0], 'olddisplay', true);