dom/tests/mochitest/ajax/jquery/test/unit/dimensions.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/ajax/jquery/test/unit/dimensions.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,86 @@
     1.4 +module("dimensions");
     1.5 +
     1.6 +test("innerWidth()", function() {
     1.7 +	expect(3);
     1.8 +
     1.9 +	var $div = $("#nothiddendiv");
    1.10 +	// set styles
    1.11 +	$div.css({
    1.12 +		margin: 10,
    1.13 +		border: "2px solid #fff",
    1.14 +		width: 30
    1.15 +	});
    1.16 +	
    1.17 +	equals($div.innerWidth(), 30, "Test with margin and border");
    1.18 +	$div.css("padding", "20px");
    1.19 +	equals($div.innerWidth(), 70, "Test with margin, border and padding");
    1.20 +	$div.hide();
    1.21 +	equals($div.innerWidth(), 70, "Test hidden div");
    1.22 +	
    1.23 +	// reset styles
    1.24 +	$div.css({ display: "", border: "", padding: "", width: "", height: "" });
    1.25 +});
    1.26 +
    1.27 +test("innerHeight()", function() {
    1.28 +	expect(3);
    1.29 +	
    1.30 +	var $div = $("#nothiddendiv");
    1.31 +	// set styles
    1.32 +	$div.css({
    1.33 +		margin: 10,
    1.34 +		border: "2px solid #fff",
    1.35 +		height: 30
    1.36 +	});
    1.37 +	
    1.38 +	equals($div.innerHeight(), 30, "Test with margin and border");
    1.39 +	$div.css("padding", "20px");
    1.40 +	equals($div.innerHeight(), 70, "Test with margin, border and padding");
    1.41 +	$div.hide();
    1.42 +	equals($div.innerHeight(), 70, "Test hidden div");
    1.43 +	
    1.44 +	// reset styles
    1.45 +	$div.css({ display: "", border: "", padding: "", width: "", height: "" });
    1.46 +});
    1.47 +
    1.48 +test("outerWidth()", function() {
    1.49 +	expect(6);
    1.50 +	
    1.51 +	var $div = $("#nothiddendiv");
    1.52 +	$div.css("width", 30);
    1.53 +	
    1.54 +	equals($div.outerWidth(), 30, "Test with only width set");
    1.55 +	$div.css("padding", "20px");
    1.56 +	equals($div.outerWidth(), 70, "Test with padding");
    1.57 +	$div.css("border", "2px solid #fff");
    1.58 +	equals($div.outerWidth(), 74, "Test with padding and border");
    1.59 +	$div.css("margin", "10px");
    1.60 +	equals($div.outerWidth(), 74, "Test with padding, border and margin without margin option");
    1.61 +	$div.css("position", "absolute");
    1.62 +	equals($div.outerWidth(true), 94, "Test with padding, border and margin with margin option");
    1.63 +	$div.hide();
    1.64 +	equals($div.outerWidth(true), 94, "Test hidden div with padding, border and margin with margin option");
    1.65 +	
    1.66 +	// reset styles
    1.67 +	$div.css({ position: "", display: "", border: "", padding: "", width: "", height: "" });
    1.68 +});
    1.69 +
    1.70 +test("outerHeight()", function() {
    1.71 +	expect(6);
    1.72 +	
    1.73 +	var $div = $("#nothiddendiv");
    1.74 +	$div.css("height", 30);
    1.75 +	
    1.76 +	equals($div.outerHeight(), 30, "Test with only width set");
    1.77 +	$div.css("padding", "20px");
    1.78 +	equals($div.outerHeight(), 70, "Test with padding");
    1.79 +	$div.css("border", "2px solid #fff");
    1.80 +	equals($div.outerHeight(), 74, "Test with padding and border");
    1.81 +	$div.css("margin", "10px");
    1.82 +	equals($div.outerHeight(), 74, "Test with padding, border and margin without margin option");
    1.83 +	equals($div.outerHeight(true), 94, "Test with padding, border and margin with margin option");
    1.84 +	$div.hide();
    1.85 +	equals($div.outerHeight(true), 94, "Test hidden div with padding, border and margin with margin option");
    1.86 +	
    1.87 +	// reset styles
    1.88 +	$div.css({ display: "", border: "", padding: "", width: "", height: "" });
    1.89 +});
    1.90 \ No newline at end of file

mercurial