[Android WebViewShell] Add support for running (some) blink layout tests in WebViewShell.
[chromium-blink-merge.git] / android_webview / tools / WebViewShell / test / resources / js-test.js
blob929a80179524fabf444db4845ed04cdeb32583b5
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 debug = function debug(msg)
7 console.log(msg);
8 };
10 description = function description(msg, quiet)
12 console.log(msg);
15 finishJSTest = function finishJSTest() {
16 console.log("TEST FINISHED");
19 function isWorker()
21 // It's conceivable that someone would stub out 'document' in a worker so
22 // also check for childNodes, an arbitrary DOM-related object that is
23 // meaningless in a WorkerContext.
24 return (typeof document === 'undefined' ||
25 typeof document.childNodes === 'undefined') && !!self.importScripts;
28 function handleTestFinished() {
29 if (!window.jsTestIsAsync)
30 finishJSTest();
33 // Returns a sorted array of property names of object. This function returns
34 // not only own properties but also properties on prototype chains.
35 function getAllPropertyNames(object) {
36 var properties = [];
37 for (var property in object) {
38 properties.push(property);
40 return properties.sort();
43 if (!isWorker()) {
44 window.addEventListener('DOMContentLoaded', handleTestFinished, false);