summaryrefslogtreecommitdiffstats
path: root/chrome/test/data/History/HistoryHelper.js
blob: 93e0a946dea20d43621243f9201e09809d90e17a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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);
}