summaryrefslogtreecommitdiffstats
path: root/chrome/test/data
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test/data')
-rw-r--r--chrome/test/data/History/HistoryHelper.js55
-rw-r--r--chrome/test/data/History/history_length_test1.html66
-rw-r--r--chrome/test/data/History/history_length_test2.html33
3 files changed, 154 insertions, 0 deletions
diff --git a/chrome/test/data/History/HistoryHelper.js b/chrome/test/data/History/HistoryHelper.js
new file mode 100644
index 0000000..93e0a94
--- /dev/null
+++ b/chrome/test/data/History/HistoryHelper.js
@@ -0,0 +1,55 @@
+//
+// This script provides some mechanics for testing History
+//
+function onSuccess(name, id)
+{
+ setTimeout(onFinished, 0, name, id, "OK");
+}
+
+function onFailure(name, id, status)
+{
+ setTimeout(onFinished, 0, name, id, status);
+}
+
+// Finish running a test by setting the status
+// and the cookie.
+function onFinished(name, id, result)
+{
+ var statusPanel = document.getElementById("statusPanel");
+ if (statusPanel) {
+ statusPanel.innerHTML = result;
+ }
+
+ var cookie = name + "." + id + ".status=" + result + "; path=/";
+ document.cookie = cookie;
+}
+
+function readCookie(name) {
+ var cookie_name = name + "=";
+ var ca = document.cookie.split(';');
+
+ for(var i = 0 ; i < ca.length ; i++) {
+ var c = ca[i];
+ while (c.charAt(0) == ' ') {
+ c = c.substring(1,c.length);
+ }
+ if (c.indexOf(cookie_name) == 0) {
+ return c.substring(cookie_name.length, c.length);
+ }
+ }
+ return null;
+}
+
+function createCookie(name,value,days) {
+ var expires = "";
+ if (days) {
+ var date = new Date();
+ date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
+ expires = "; expires=" + date.toGMTString();
+ }
+ document.cookie = name+"="+value+expires+"; path=/";
+}
+
+function eraseCookie(name) {
+ createCookie(name, "", -1);
+}
diff --git a/chrome/test/data/History/history_length_test1.html b/chrome/test/data/History/history_length_test1.html
new file mode 100644
index 0000000..4a44fa9
--- /dev/null
+++ b/chrome/test/data/History/history_length_test1.html
@@ -0,0 +1,66 @@
+<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");
+ 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");
+ 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
new file mode 100644
index 0000000..2bae3ac
--- /dev/null
+++ b/chrome/test/data/History/history_length_test2.html
@@ -0,0 +1,33 @@
+<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");
+ alert(window.history.length);
+ return false;
+ }
+
+ window.history.back();
+ return true;
+}
+
+function OnEchoHistory() {
+ alert(window.history.length);
+}
+
+</SCRIPT>
+</html> \ No newline at end of file