Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: LayoutTests/http/tests/inspector-protocol/resources/protocol-test.js

Issue 183663014: DevTools: Unify protocol test scripts naming with frontend tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed tests Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 var outputElement;
27
28 /**
29 * Logs message to process stdout via alert (hopefully implemented with immediat e flush).
30 * @param {string} text
31 */
32 function debugLog(text)
33 {
34 alert(text);
35 }
36
37 /**
38 * @param {string} text
39 */
40 function log(text)
41 {
42 if (!outputElement) {
43 var intermediate = document.createElement("div");
44 document.body.appendChild(intermediate);
45
46 var intermediate2 = document.createElement("div");
47 intermediate.appendChild(intermediate2);
48
49 outputElement = document.createElement("div");
50 outputElement.className = "output";
51 outputElement.id = "output";
52 outputElement.style.whiteSpace = "pre";
53 intermediate2.appendChild(outputElement);
54 }
55 outputElement.appendChild(document.createTextNode(text));
56 outputElement.appendChild(document.createElement("br"));
57 }
58
59 function closeTest()
60 {
61 closeInspector();
62 testRunner.notifyDone();
63 }
64
65 function runTest()
66 {
67 if (!window.testRunner) {
68 console.error("This test requires DumpRenderTree");
69 return;
70 }
71 testRunner.dumpAsText();
72 testRunner.waitUntilDone();
73 testRunner.setCanOpenWindows(true);
74
75 openInspector();
76 }
77
78 function closeInspector()
79 {
80 window.internals.closeDummyInspectorFrontend();
81 }
82
83 function openInspector()
84 {
85 var scriptTags = document.getElementsByTagName("script");
86 var scriptUrlBasePath = "";
87 for (var i = 0; i < scriptTags.length; ++i) {
88 var index = scriptTags[i].src.lastIndexOf("/protocol-test.js");
89 if (index > -1 ) {
90 scriptUrlBasePath = scriptTags[i].src.slice(0, index);
91 break;
92 }
93 }
94
95 var dummyFrontendURL = scriptUrlBasePath + "/protocol-test.html";
96 var inspectorFrontend = window.internals.openDummyInspectorFrontend(dummyFro ntendURL);
97 inspectorFrontend.addEventListener("load", function(event) {
98 // FIXME: rename this 'test' global field across all tests.
99 var testFunction = window.test;
100 if (typeof testFunction === "function") {
101 var initializers = "";
102 for (var symbol in window) {
103 if (!/^initialize_/.test(symbol) || typeof window[symbol] !== "f unction")
104 continue;
105 initializers += "(" + window[symbol].toString() + ")();\n";
106 }
107 inspectorFrontend.postMessage(initializers + "(" + testFunction.toSt ring() +")();", "*");
108 return;
109 }
110 // Kill waiting process if failed to send.
111 alert("Failed to send test function");
112 testRunner.notifyDone();
113 });
114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698