2 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 var initialize_InspectorTest = function() {
29 InspectorTest
.evaluateInInspectedPage = function(expression
, callback
)
31 InspectorTest
.sendCommand("Runtime.evaluate", { expression
: expression
}, callback
);
39 * Logs message to process stdout via alert (hopefully implemented with immediate flush).
40 * @param {string} text
42 function debugLog(text
)
48 * @param {string} text
53 var intermediate
= document
.createElement("div");
54 document
.body
.appendChild(intermediate
);
56 var intermediate2
= document
.createElement("div");
57 intermediate
.appendChild(intermediate2
);
59 outputElement
= document
.createElement("div");
60 outputElement
.className
= "output";
61 outputElement
.id
= "output";
62 outputElement
.style
.whiteSpace
= "pre";
63 intermediate2
.appendChild(outputElement
);
65 outputElement
.appendChild(document
.createTextNode(text
));
66 outputElement
.appendChild(document
.createElement("br"));
72 testRunner
.notifyDone();
77 if (!window
.testRunner
) {
78 console
.error("This test requires DumpRenderTree");
81 testRunner
.dumpAsText();
82 testRunner
.waitUntilDone();
83 testRunner
.setCanOpenWindows(true);
88 function closeInspector()
90 testRunner
.closeWebInspector();
93 var lastFrontendEvalId
= 0;
94 function evaluateInFrontend(script
)
96 testRunner
.evaluateInWebInspector(++lastFrontendEvalId
, script
);
99 function openInspector()
101 var scriptTags
= document
.getElementsByTagName("script");
102 var scriptUrlBasePath
= "";
103 for (var i
= 0; i
< scriptTags
.length
; ++i
) {
104 var index
= scriptTags
[i
].src
.lastIndexOf("/inspector-protocol-test.js");
106 scriptUrlBasePath
= scriptTags
[i
].src
.slice(0, index
);
111 var dummyFrontendURL
= scriptUrlBasePath
+ "/resources/protocol-test.html";
112 testRunner
.showWebInspector("", dummyFrontendURL
);
113 // FIXME: rename this 'test' global field across all tests.
114 var testFunction
= window
.test
;
115 if (typeof testFunction
=== "function") {
116 var initializers
= "";
117 for (var symbol
in window
) {
118 if (!/^initialize_/.test(symbol
) || typeof window
[symbol
] !== "function")
120 initializers
+= "(" + window
[symbol
].toString() + ")();\n";
122 evaluateInFrontend(initializers
+ "(" + testFunction
.toString() +")();");
125 // Kill waiting process if failed to send.
126 alert("Failed to send test function");
127 testRunner
.notifyDone();