2010-06-19 Hayato Ito <hayato@chromium.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 20 Jun 2010 01:03:37 +0000 (01:03 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 20 Jun 2010 01:03:37 +0000 (01:03 +0000)
        Reviewed by Adam Barth.

        Add tests for CSS 'orphans' and 'widows' properties.
        All tests are expected to fail due to lack of implementations.

        https://bugs.webkit.org/show_bug.cgi?id=40821

        * printing/page-break-orphans-and-widows-expected.txt: Added.
        * printing/page-break-orphans-and-widows.html: Added.
        * printing/page-break-orphans-expected.txt: Added.
        * printing/page-break-orphans.html: Added.
        * printing/page-break-widows-expected.txt: Added.
        * printing/page-break-widows.html: Added.
        * printing/script-tests/page-break-orphans-and-widows.js: Added.
        (test):
        * printing/script-tests/page-break-orphans.js: Added.
        (test):
        * printing/script-tests/page-break-widows.js: Added.
        (test):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@61502 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/printing/page-break-orphans-and-widows-expected.txt [new file with mode: 0644]
LayoutTests/printing/page-break-orphans-and-widows.html [new file with mode: 0644]
LayoutTests/printing/page-break-orphans-expected.txt [new file with mode: 0644]
LayoutTests/printing/page-break-orphans.html [new file with mode: 0644]
LayoutTests/printing/page-break-widows-expected.txt [new file with mode: 0644]
LayoutTests/printing/page-break-widows.html [new file with mode: 0644]
LayoutTests/printing/script-tests/page-break-orphans-and-widows.js [new file with mode: 0644]
LayoutTests/printing/script-tests/page-break-orphans.js [new file with mode: 0644]
LayoutTests/printing/script-tests/page-break-widows.js [new file with mode: 0644]

index 280c167..7da6746 100644 (file)
@@ -2,6 +2,28 @@
 
         Reviewed by Adam Barth.
 
+        Add tests for CSS 'orphans' and 'widows' properties.
+        All tests are expected to fail due to lack of implementations.
+
+        https://bugs.webkit.org/show_bug.cgi?id=40821
+
+        * printing/page-break-orphans-and-widows-expected.txt: Added.
+        * printing/page-break-orphans-and-widows.html: Added.
+        * printing/page-break-orphans-expected.txt: Added.
+        * printing/page-break-orphans.html: Added.
+        * printing/page-break-widows-expected.txt: Added.
+        * printing/page-break-widows.html: Added.
+        * printing/script-tests/page-break-orphans-and-widows.js: Added.
+        (test):
+        * printing/script-tests/page-break-orphans.js: Added.
+        (test):
+        * printing/script-tests/page-break-widows.js: Added.
+        (test):
+
+2010-06-19  Hayato Ito  <hayato@chromium.org>
+
+        Reviewed by Adam Barth.
+
         Add tests for 'page-break-{before,after}: avoid'.
         All tests are expected to fail due to lack of implementations.
 
diff --git a/LayoutTests/printing/page-break-orphans-and-widows-expected.txt b/LayoutTests/printing/page-break-orphans-and-widows-expected.txt
new file mode 100644 (file)
index 0000000..feeea09
--- /dev/null
@@ -0,0 +1,23 @@
+Test for orphans and widows
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+PASS: page number of "page1-1" is 1
+PASS: page number of "page1-2" is 1
+PASS: page number of "page1-3" is 1
+PASS: page number of "page2" is 2
+FAIL: expected page number of "page3" is 3. Was 2
+PASS: page number of "page4" is 4
+FAIL: expected page number of "page5" is 5. Was 4
+PASS: page number of "page6-1" is 6
+PASS: page number of "page6-2" is 6
+PASS: page number of "page7" is 7
+PASS: page number of "page8" is 8
+FAIL: expected page number of "page9" is 9. Was 8
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/printing/page-break-orphans-and-widows.html b/LayoutTests/printing/page-break-orphans-and-widows.html
new file mode 100644 (file)
index 0000000..1b2b104
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script src="../fast/js/resources/js-test-pre.js"></script>
+<script src="resources/paged-media-test-utils.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<div id="sandbox"></div>
+<script src="script-tests/page-break-orphans-and-widows.js"></script>
+<script>runPrintingTest(test);</script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/printing/page-break-orphans-expected.txt b/LayoutTests/printing/page-break-orphans-expected.txt
new file mode 100644 (file)
index 0000000..2127aaa
--- /dev/null
@@ -0,0 +1,17 @@
+Test for orphans
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+PASS: page number of "page1-1" is 1
+PASS: page number of "page1-2" is 1
+PASS: page number of "page3" is 3
+FAIL: expected page number of "page4" is 4. Was 3
+PASS: page number of "page5-1" is 5
+PASS: page number of "page5-2" is 5
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/printing/page-break-orphans.html b/LayoutTests/printing/page-break-orphans.html
new file mode 100644 (file)
index 0000000..5413d4f
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script src="../fast/js/resources/js-test-pre.js"></script>
+<script src="resources/paged-media-test-utils.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<div id="sandbox"></div>
+<script src="script-tests/page-break-orphans.js"></script>
+<script>runPrintingTest(test);</script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/printing/page-break-widows-expected.txt b/LayoutTests/printing/page-break-widows-expected.txt
new file mode 100644 (file)
index 0000000..f40e460
--- /dev/null
@@ -0,0 +1,19 @@
+Test for widows
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+PASS: page number of "page1-1" is 1
+PASS: page number of "page1-2" is 1
+PASS: page number of "page2-1" is 2
+PASS: page number of "page2-2" is 2
+PASS: page number of "page3-1" is 3
+PASS: page number of "page3-2" is 3
+PASS: page number of "page4" is 4
+FAIL: expected page number of "page5" is 5. Was 4
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/printing/page-break-widows.html b/LayoutTests/printing/page-break-widows.html
new file mode 100644 (file)
index 0000000..dd0fdda
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script src="../fast/js/resources/js-test-pre.js"></script>
+<script src="resources/paged-media-test-utils.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<div id="sandbox"></div>
+<script src="script-tests/page-break-widows.js"></script>
+<script>runPrintingTest(test);</script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/printing/script-tests/page-break-orphans-and-widows.js b/LayoutTests/printing/script-tests/page-break-orphans-and-widows.js
new file mode 100644 (file)
index 0000000..2b1edfd
--- /dev/null
@@ -0,0 +1,64 @@
+description("Test for orphans and widows");
+
+function test()
+{
+    var block;
+    createBlockWithNumberOfLines("page1-1", 10).style.pageBreakBefore = "always";
+    // 10 lines lines are available in the current page.
+    block = createBlockWithNumberOfLines("page1-2", 9);
+    block.style.orphans = 10;
+    block.style.widows = 20;
+    // block 'page1-2' can be placed on the current page.
+    createBlockWithRatioToPageHeight("page1-3", 0.01);
+
+    createBlockWithNumberOfLines("page2", 10).style.pageBreakBefore = "always";
+    // 10 lines lines are available in the current page.
+    block = createBlockWithNumberOfLines("page3", 12);
+    block.style.orphans = 15;
+    block.style.widows = 2;
+    // block 'page3' must move as a block to the next page because of 'orphans'.
+
+    createBlockWithNumberOfLines("page4", 10).style.pageBreakBefore = "always";
+    // 10 lines lines are available in the current page.
+    block = createBlockWithNumberOfLines("page5", 12);
+    block.style.orphans = 2;
+    block.style.widows = 15;
+    // block 'page5' must move as a block to the next page because of 'widows'.
+
+    createBlockWithNumberOfLines("page6-1", 10).style.pageBreakBefore = "always";
+    // 10 lines lines are available in the current page.
+    block = createBlockWithNumberOfLines("page6-2", 12);
+    block.style.orphans = 6;
+    block.style.widows = 6;
+    // block 'page6' must be splitted.
+    createBlockWithRatioToPageHeight("page7", 0.01);
+
+    createBlockWithNumberOfLines("page8", 10).style.pageBreakBefore = "always";
+    // 10 lines lines are available in the current page.
+    block = createBlockWithNumberOfLines("page9", 12);
+    block.style.orphans = 10;
+    block.style.widows = 10;
+    // block 'page9' must move as a block to the next page because we cannot satisfy
+    // both 'orphans' and 'widows' at the same time.
+
+    pageNumberForElementShouldBe("page1-1", 1);
+    pageNumberForElementShouldBe("page1-2", 1);
+    pageNumberForElementShouldBe("page1-3", 1);
+
+    pageNumberForElementShouldBe("page2", 2);
+    pageNumberForElementShouldBe("page3", 3);
+
+    pageNumberForElementShouldBe("page4", 4);
+    pageNumberForElementShouldBe("page5", 5);
+
+    pageNumberForElementShouldBe("page6-1", 6);
+    pageNumberForElementShouldBe("page6-2", 6);
+    pageNumberForElementShouldBe("page7", 7);
+
+    pageNumberForElementShouldBe("page8", 8);
+    pageNumberForElementShouldBe("page9", 9);
+
+    document.body.removeChild(document.getElementById("sandbox"));
+}
+
+var successfullyParsed = true;
diff --git a/LayoutTests/printing/script-tests/page-break-orphans.js b/LayoutTests/printing/script-tests/page-break-orphans.js
new file mode 100644 (file)
index 0000000..fc9aded
--- /dev/null
@@ -0,0 +1,29 @@
+description("Test for orphans");
+
+function test()
+{
+    createBlockWithRatioToPageHeight("page1-1", 0.5).style.pageBreakBefore = "always";
+    // Here about 10 lines are avaliable at the bottom of the current page.
+    createBlockWithNumberOfLines("page1-2", 15).style.orphans = 8;
+
+    createBlockWithRatioToPageHeight("page3", 0.5).style.pageBreakBefore = "always";
+    // we should put 'page4' block in the next page because of orphans.
+    createBlockWithNumberOfLines("page4", 15).style.orphans = 12;
+
+    createBlockWithRatioToPageHeight("page5-1", 0.5).style.pageBreakBefore = "always";
+    // '-1' is acceptable as a value of orphans. But it should have no effect.
+    createBlockWithNumberOfLines("page5-2", 20).style.orphans = -1;
+
+    pageNumberForElementShouldBe("page1-1", 1);
+    pageNumberForElementShouldBe("page1-2", 1);
+
+    pageNumberForElementShouldBe("page3", 3);
+    pageNumberForElementShouldBe("page4", 4);
+
+    pageNumberForElementShouldBe("page5-1", 5);
+    pageNumberForElementShouldBe("page5-2", 5);
+
+    document.body.removeChild(document.getElementById("sandbox"));
+}
+
+var successfullyParsed = true;
diff --git a/LayoutTests/printing/script-tests/page-break-widows.js b/LayoutTests/printing/script-tests/page-break-widows.js
new file mode 100644 (file)
index 0000000..da5c72a
--- /dev/null
@@ -0,0 +1,34 @@
+description("Test for widows");
+
+function test()
+{
+    createBlockWithRatioToPageHeight("page1-1", 0.5).style.pageBreakBefore = "always";
+    // Here about 10 lines are avaliable at the bottom of the current page.
+    // We can leave about 5 lines in the next page. It doesn't violate widows restriction.
+    createBlockWithNumberOfLines("page1-2", 15).style.widows = 2;
+    // Here about 15 lines should be available in the current page.
+    createBlockWithNumberOfLines("page2-1", 10);
+    createBlockWithNumberOfLines("page2-2", 2);
+
+    createBlockWithRatioToPageHeight("page3-1", 0.5).style.pageBreakBefore = "always";
+    // The second part of 'page3-2' block must contain at least 12 lines in the next page.
+    // So the block must be separated in earlier position.
+    createBlockWithNumberOfLines("page3-2", 15).style.widows = 12;
+    // Here at most 8 (= 20 - 12) lines should be available.
+    createBlockWithNumberOfLines("page4", 10);
+    createBlockWithNumberOfLines("page5", 2);
+
+    pageNumberForElementShouldBe("page1-1", 1);
+    pageNumberForElementShouldBe("page1-2", 1);
+    pageNumberForElementShouldBe("page2-1", 2);
+    pageNumberForElementShouldBe("page2-2", 2);
+
+    pageNumberForElementShouldBe("page3-1", 3);
+    pageNumberForElementShouldBe("page3-2", 3);
+    pageNumberForElementShouldBe("page4", 4);
+    pageNumberForElementShouldBe("page5", 5);
+
+    document.body.removeChild(document.getElementById("sandbox"));
+}
+
+var successfullyParsed = true;