summaryrefslogtreecommitdiffstats
path: root/chrome/test/data/prerender/prerender_visibility_shared.js
blob: 1d82f94692faff36010bf8f3fc515f1d1b985ba5 (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
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Code shared by some of the visibility tests.  Maintains a list of
// visibility states, starting with the state when this file was loaded.
// New states are added on each visibility change event.

// Array of previously observed visibility states.
var visibilityStates = [document.webkitVisibilityState];

// Array of previously observed hidden values.
var hiddenValues = [document.webkitHidden];

// Record all visibility changes in corresponding arrays.
function onVisibilityChange(event) {
  visibilityStates.push(document.webkitVisibilityState);
  hiddenValues.push(document.webkitHidden);
}

document.addEventListener("webkitvisibilitychange",
                          onVisibilityChange,
                          false);