Skip to content

Commit 5d404d4

Browse files
Skip window-resizing tests if programmatic window resizing isn't enabled by the browser.
1 parent 2d41b51 commit 5d404d4

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

test/unit/dom_test.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ var createParagraph = function(text) {
77
return p;
88
}
99

10+
var RESIZE_DISABLED = false;
11+
1012
function simulateClick(node) {
1113
var oEvent;
1214
if (document.createEvent) {
@@ -1473,9 +1475,19 @@ new Test.Unit.Runner({
14731475
window.resizeBy(50, 50);
14741476
this.wait(1000, function() {
14751477
var after = document.viewport.getDimensions();
1478+
1479+
// Assume that JavaScript window resizing is disabled if before width
1480+
// and after width are the same.
1481+
if (before.width === after.width) {
1482+
RESIZE_DISABLED = true;
1483+
this.info("SKIPPING REMAINING TESTS (JavaScript window resizing disabled)");
1484+
return;
1485+
}
14761486

1477-
this.assertEqual(before.width + 50, after.width, "NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THIS TEST TO PASS");
1478-
this.assertEqual(before.height + 50, after.height, "NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THIS TEST TO PASS");
1487+
this.assertEqual(before.width + 50, after.width,
1488+
"NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THIS TEST TO PASS");
1489+
this.assertEqual(before.height + 50, after.height,
1490+
"NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THIS TEST TO PASS");
14791491

14801492
this.wait(1000, function() {
14811493
// Restore original dimensions.
@@ -1512,14 +1524,20 @@ new Test.Unit.Runner({
15121524
window.scrollTo(0, 35);
15131525
this.assertEqual(35, document.viewport.getScrollOffsets().top);
15141526

1527+
if (RESIZE_DISABLED) {
1528+
this.info("SKIPPING REMAINING TESTS (JavaScript window resizing disabled)");
1529+
return;
1530+
}
1531+
15151532
window.resizeTo(200, 650);
15161533

15171534
this.wait(1000, function() {
15181535
var before = document.viewport.getDimensions();
15191536
var delta = { width: 200 - before.width, height: 650 - before.height };
15201537

15211538
window.scrollTo(25, 35);
1522-
this.assertEqual(25, document.viewport.getScrollOffsets().left, "NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THESE TESTS TO PASS");
1539+
this.assertEqual(25, document.viewport.getScrollOffsets().left,
1540+
"NOTE: YOU MUST ALLOW JAVASCRIPT TO RESIZE YOUR WINDOW FOR THESE TESTS TO PASS");
15231541

15241542
this.wait(1000, function() {
15251543
// Restore original dimensions.

0 commit comments

Comments
 (0)