diff options
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/data/History/HistoryHelper.js | 3 | ||||
-rw-r--r-- | chrome/test/data/History/history_length_test1.html | 66 | ||||
-rw-r--r-- | chrome/test/data/History/history_length_test2.html | 32 | ||||
-rw-r--r-- | chrome/test/data/History/history_length_test_page_1.html | 46 | ||||
-rw-r--r-- | chrome/test/data/History/history_length_test_page_2.html | 37 | ||||
-rw-r--r-- | chrome/test/data/History/history_length_test_page_3.html | 58 | ||||
-rw-r--r-- | chrome/test/data/History/history_length_test_page_4.html | 48 | ||||
-rw-r--r-- | chrome/test/ui/history_uitest.cc | 35 |
8 files changed, 223 insertions, 102 deletions
diff --git a/chrome/test/data/History/HistoryHelper.js b/chrome/test/data/History/HistoryHelper.js index 93e0a94..efd2369 100644 --- a/chrome/test/data/History/HistoryHelper.js +++ b/chrome/test/data/History/HistoryHelper.js @@ -53,3 +53,6 @@ function createCookie(name,value,days) { function eraseCookie(name) { createCookie(name, "", -1); } + +var navigate_backward_cookie = "Navigate_Backward_Cookie"; +var navigate_forward_cookie = "Navigate_Forward_Cookie"; diff --git a/chrome/test/data/History/history_length_test1.html b/chrome/test/data/History/history_length_test1.html index 5700661..e69de29 100644 --- a/chrome/test/data/History/history_length_test1.html +++ b/chrome/test/data/History/history_length_test1.html @@ -1,66 +0,0 @@ -<html> -<head><title>History test1</title> -<script src="HistoryHelper.js"></script> -</head> - -<body onload="onLoad();"> -<div id="statusPanel" style="border: 1px solid red; width: 100%"> -History Test1 running.... -</body> - -<SCRIPT type="text/javascript"> -var first_run_cookie = "First_History_Test_Run"; -var second_run_cookie = "Second_History_Test_Run"; - -function onLoad() { - if (readCookie(second_run_cookie) != null) { - setTimeout(OnValidateHistoryForSecondRun, 100); - return true; - } - - if (readCookie(first_run_cookie) != null) { - setTimeout(OnMoveForwardInHistory, 100); - return true; - } - - setTimeout(OnNavigateToPage2, 100); - return true; -} - -function OnValidateHistoryForSecondRun() { - eraseCookie(first_run_cookie); - eraseCookie(second_run_cookie); - - if (window.history.length != 2) { - onFailure("History_Length_Test", 1, "Second run history length mismatch"); - return false; - } - - onSuccess("History_Length_Test", 1); - return true; -} - -function OnMoveForwardInHistory() { - if (window.history.length != 2) { - onFailure("History_Length_Test", 1, "History length mismatch in MoveForward navigation"); - return false; - } - - createCookie(second_run_cookie, "1", "1"); - window.history.forward(); - return true; -} - -function OnNavigateToPage2() { - if (window.history.length != 2) { - onFailure("History_Length_Test", 1, "History length mismatch in initial navigation"); - return false; - } - - createCookie(first_run_cookie, "1", "1"); - window.location.href = "history_length_test2.html"; - return true; -} - -</SCRIPT> -</html>
\ No newline at end of file diff --git a/chrome/test/data/History/history_length_test2.html b/chrome/test/data/History/history_length_test2.html index 39b5ebc..e69de29 100644 --- a/chrome/test/data/History/history_length_test2.html +++ b/chrome/test/data/History/history_length_test2.html @@ -1,32 +0,0 @@ -<html> -<head><title>History test2</title> -<script src="HistoryHelper.js"></script> -</head> - -<body onload="onLoad();"> -<div id="statusPanel" style="border: 1px solid red; width: 100%"> -History test2.... -<div id="Div1" style="border: 1px solid red; width: 100%"> -</body> - -<SCRIPT type="text/javascript"> -function onLoad() { - setTimeout(OnValidateHistoryLength, 100); -} - -function OnValidateHistoryLength() { - if (window.history.length != 3) { - onFailure("History_Length_Test", 1, "History length mismatch in second page OnLoad"); - return false; - } - - window.history.back(); - return true; -} - -function OnEchoHistory() { - alert(window.history.length); -} - -</SCRIPT> -</html>
\ No newline at end of file diff --git a/chrome/test/data/History/history_length_test_page_1.html b/chrome/test/data/History/history_length_test_page_1.html new file mode 100644 index 0000000..b0bfdaf --- /dev/null +++ b/chrome/test/data/History/history_length_test_page_1.html @@ -0,0 +1,46 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<head><title>History Test Page 1</title> +<script type="text/javascript" src="HistoryHelper.js"></script> +</head> + +<body onload="onLoad();"> +<div id="statusPanel" style="border: 1px solid red; width: 100%"> +History Test Page 1.... +</div> +</body> + +<script type="text/javascript"> + +function onLoad() { + if (readCookie(navigate_backward_cookie) != null) { + setTimeout(OnNavigateBackward, 100); + return true; + } + setTimeout(OnInitialLoad, 100); + return true; +} + +function OnNavigateBackward() { + if (window.history.length != 2) { + onFailure("History_Length_Test_3", 1, + "History length mismatch on navigate backward at page 1"); + return false; + } + // Navigate forward from this point on. + createCookie(navigate_forward_cookie, "1", "1"); + window.history.forward(); + return true; +} + +function OnInitialLoad() { + if (window.history.length != 2) { + onFailure("History_Length_Test_1", 1, + "History length mismatch on initial load at page 1"); + return false; + } + onSuccess("History_Length_Test_1", 1); + return true; +} + +</script> +</html>
\ No newline at end of file diff --git a/chrome/test/data/History/history_length_test_page_2.html b/chrome/test/data/History/history_length_test_page_2.html new file mode 100644 index 0000000..edcecfe --- /dev/null +++ b/chrome/test/data/History/history_length_test_page_2.html @@ -0,0 +1,37 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<head><title>History Test Page 2</title> +<script type="text/javascript" src="HistoryHelper.js"></script> +</head> + +<body onload="onLoad();"> +<div id="statusPanel" style="border: 1px solid red; width: 100%"> +History Test Page 2.... +</div> +</body> + +<script type="text/javascript"> + +function onLoad() { + if (readCookie(navigate_backward_cookie) != null || + readCookie(navigate_forward_cookie) != null) { + onFailure("History_Length_Test_3", 1, + "Page 2 must not be visited in navigating backward/forward"); + return false; + } + setTimeout(OnInitialLoad, 100); + return true; +} + +function OnInitialLoad() { + if (window.history.length != 3) { + onFailure("History_Length_Test_2", 1, + "History length mismatch on initial load at page 2"); + return false; + } + // Redirect to page 3. + window.location.href = "history_length_test_page_3.html"; + return true; +} + +</script> +</html>
\ No newline at end of file diff --git a/chrome/test/data/History/history_length_test_page_3.html b/chrome/test/data/History/history_length_test_page_3.html new file mode 100644 index 0000000..4c9a0a0 --- /dev/null +++ b/chrome/test/data/History/history_length_test_page_3.html @@ -0,0 +1,58 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<head><title>History Test Page 3</title> +<script src="HistoryHelper.js"></script> +</head> + +<body onload="onLoad();"> +<div id="statusPanel" style="border: 1px solid red; width: 100%"> +History Test Page 3.... +</div> +</body> + +<script type="text/javascript"> + +function onLoad() { + if (readCookie(navigate_forward_cookie) != null) { + setTimeout(OnNavigateForward, 100); + return true; + } + if (readCookie(navigate_backward_cookie)) { + setTimeout(OnNavigateBackward, 100); + return true; + } + setTimeout(OnInitialLoad, 100); + return true; +} + +function OnInitialLoad() { + if (window.history.length != 3) { + onFailure("History_Length_Test_2", 1, + "History length mismatch on initial load at page 3"); + return false; + } + onSuccess("History_Length_Test_2", 1); + return true; +} + +function OnNavigateBackward() { + if (window.history.length != 3) { + onFailure("History_Length_Test_3", 1, + "History length mismatch on navigating backward at page 3"); + return false; + } + window.history.back(); + return true; +} + +function OnNavigateForward() { + if (window.history.length != 3) { + onFailure("History_Length_Test_3", 1, + "History length mismatch on navigating forward at page 3"); + return false; + } + window.history.forward(); + return true; +} + +</script> +</html>
\ No newline at end of file diff --git a/chrome/test/data/History/history_length_test_page_4.html b/chrome/test/data/History/history_length_test_page_4.html new file mode 100644 index 0000000..a72889c --- /dev/null +++ b/chrome/test/data/History/history_length_test_page_4.html @@ -0,0 +1,48 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<head><title>History Test Page 4</title> +<script src="HistoryHelper.js"></script> +</head> + +<body onload="onLoad();"> +<div id="statusPanel" style="border: 1px solid red; width: 100%"> +History Test Page 4.... +</div> +</body> + +<SCRIPT type="text/javascript"> + +function onLoad() { + if (readCookie(navigate_forward_cookie) != null) { + setTimeout(OnNavigateForward, 100); + return true; + } + setTimeout(OnInitialLoad, 100); + return true; +} + +function OnInitialLoad() { + if (window.history.length != 4) { + onFailure("History_Length_Test_3", 1, + "History length mismatch on initial load at page 4"); + return false; + } + // Navigate backward from this point on. + createCookie(navigate_backward_cookie, "1", "1"); + window.history.back(); + return true; +} + +function OnNavigateForward() { + if (window.history.length != 4) { + onFailure("History_Length_Test_3", 1, + "History length mismatch on navigating forward at page 4"); + return false; + } + eraseCookie(navigate_forward_cookie); + eraseCookie(navigate_backward_cookie); + onSuccess("History_Length_Test_3", 1); + return true; +} + +</SCRIPT> +</html>
\ No newline at end of file diff --git a/chrome/test/ui/history_uitest.cc b/chrome/test/ui/history_uitest.cc index 25ee75e..11be6ff 100644 --- a/chrome/test/ui/history_uitest.cc +++ b/chrome/test/ui/history_uitest.cc @@ -49,9 +49,36 @@ class HistoryTester : public UITest { }; TEST_F(HistoryTester, VerifyHistoryLength) { - std::wstring test_case = L"history_length_test1.html"; - GURL url = GetTestUrl(L"History", test_case); - NavigateToURL(url); - WaitForFinish("History_Length_Test", "1", url, kTestCompleteCookie, + // Test the history length for the following page transitions. + // + // Test case 1: + // -open-> Page 1. + // Test case 2: + // -open-> Page 2 -redirect-> Page 3. + // Test case 3: + // -open-> Page 4 -navigate_backward-> Page 3 -navigate_backward->Page 1 + // -navigate_forward-> Page 3 -navigate_forward-> Page 4 + // + // Note that Page 2 is not visited on navigating backward/forward. + + // Test case 1 + std::wstring test_case_1 = L"history_length_test_page_1.html"; + GURL url_1 = GetTestUrl(L"History", test_case_1); + NavigateToURL(url_1); + WaitForFinish("History_Length_Test_1", "1", url_1, kTestCompleteCookie, + kTestCompleteSuccess, action_max_timeout_ms()); + + // Test case 2 + std::wstring test_case_2 = L"history_length_test_page_2.html"; + GURL url_2 = GetTestUrl(L"History", test_case_2); + NavigateToURL(url_2); + WaitForFinish("History_Length_Test_2", "1", url_2, kTestCompleteCookie, + kTestCompleteSuccess, action_max_timeout_ms()); + + // Test case 3 + std::wstring test_case_3 = L"history_length_test_page_4.html"; + GURL url_3 = GetTestUrl(L"History", test_case_3); + NavigateToURL(url_3); + WaitForFinish("History_Length_Test_3", "1", url_3, kTestCompleteCookie, kTestCompleteSuccess, action_max_timeout_ms()); } |