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

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial