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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 module("dimensions");
michael@0 2
michael@0 3 test("innerWidth()", function() {
michael@0 4 expect(3);
michael@0 5
michael@0 6 var $div = $("#nothiddendiv");
michael@0 7 // set styles
michael@0 8 $div.css({
michael@0 9 margin: 10,
michael@0 10 border: "2px solid #fff",
michael@0 11 width: 30
michael@0 12 });
michael@0 13
michael@0 14 equals($div.innerWidth(), 30, "Test with margin and border");
michael@0 15 $div.css("padding", "20px");
michael@0 16 equals($div.innerWidth(), 70, "Test with margin, border and padding");
michael@0 17 $div.hide();
michael@0 18 equals($div.innerWidth(), 70, "Test hidden div");
michael@0 19
michael@0 20 // reset styles
michael@0 21 $div.css({ display: "", border: "", padding: "", width: "", height: "" });
michael@0 22 });
michael@0 23
michael@0 24 test("innerHeight()", function() {
michael@0 25 expect(3);
michael@0 26
michael@0 27 var $div = $("#nothiddendiv");
michael@0 28 // set styles
michael@0 29 $div.css({
michael@0 30 margin: 10,
michael@0 31 border: "2px solid #fff",
michael@0 32 height: 30
michael@0 33 });
michael@0 34
michael@0 35 equals($div.innerHeight(), 30, "Test with margin and border");
michael@0 36 $div.css("padding", "20px");
michael@0 37 equals($div.innerHeight(), 70, "Test with margin, border and padding");
michael@0 38 $div.hide();
michael@0 39 equals($div.innerHeight(), 70, "Test hidden div");
michael@0 40
michael@0 41 // reset styles
michael@0 42 $div.css({ display: "", border: "", padding: "", width: "", height: "" });
michael@0 43 });
michael@0 44
michael@0 45 test("outerWidth()", function() {
michael@0 46 expect(6);
michael@0 47
michael@0 48 var $div = $("#nothiddendiv");
michael@0 49 $div.css("width", 30);
michael@0 50
michael@0 51 equals($div.outerWidth(), 30, "Test with only width set");
michael@0 52 $div.css("padding", "20px");
michael@0 53 equals($div.outerWidth(), 70, "Test with padding");
michael@0 54 $div.css("border", "2px solid #fff");
michael@0 55 equals($div.outerWidth(), 74, "Test with padding and border");
michael@0 56 $div.css("margin", "10px");
michael@0 57 equals($div.outerWidth(), 74, "Test with padding, border and margin without margin option");
michael@0 58 $div.css("position", "absolute");
michael@0 59 equals($div.outerWidth(true), 94, "Test with padding, border and margin with margin option");
michael@0 60 $div.hide();
michael@0 61 equals($div.outerWidth(true), 94, "Test hidden div with padding, border and margin with margin option");
michael@0 62
michael@0 63 // reset styles
michael@0 64 $div.css({ position: "", display: "", border: "", padding: "", width: "", height: "" });
michael@0 65 });
michael@0 66
michael@0 67 test("outerHeight()", function() {
michael@0 68 expect(6);
michael@0 69
michael@0 70 var $div = $("#nothiddendiv");
michael@0 71 $div.css("height", 30);
michael@0 72
michael@0 73 equals($div.outerHeight(), 30, "Test with only width set");
michael@0 74 $div.css("padding", "20px");
michael@0 75 equals($div.outerHeight(), 70, "Test with padding");
michael@0 76 $div.css("border", "2px solid #fff");
michael@0 77 equals($div.outerHeight(), 74, "Test with padding and border");
michael@0 78 $div.css("margin", "10px");
michael@0 79 equals($div.outerHeight(), 74, "Test with padding, border and margin without margin option");
michael@0 80 equals($div.outerHeight(true), 94, "Test with padding, border and margin with margin option");
michael@0 81 $div.hide();
michael@0 82 equals($div.outerHeight(true), 94, "Test hidden div with padding, border and margin with margin option");
michael@0 83
michael@0 84 // reset styles
michael@0 85 $div.css({ display: "", border: "", padding: "", width: "", height: "" });
michael@0 86 });

mercurial