OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Samsung Electronics. All rights reserved. | 2 * Copyright (C) 2012 Samsung Electronics. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
13 * | 13 * |
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 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 | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 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 | 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
| 25 |
25 var outputElement; | 26 var outputElement; |
26 | 27 |
27 /** | 28 /** |
28 * Logs message to process stdout via alert (hopefully implemented with immediat
e flush). | 29 * Logs message to process stdout via alert (hopefully implemented with immediat
e flush). |
29 * @param {string} text | 30 * @param {string} text |
30 */ | 31 */ |
31 function debugLog(text) | 32 function debugLog(text) |
32 { | 33 { |
33 alert(text); | 34 alert(text); |
34 } | 35 } |
(...skipping 15 matching lines...) Expand all Loading... |
50 outputElement.id = "output"; | 51 outputElement.id = "output"; |
51 outputElement.style.whiteSpace = "pre"; | 52 outputElement.style.whiteSpace = "pre"; |
52 intermediate2.appendChild(outputElement); | 53 intermediate2.appendChild(outputElement); |
53 } | 54 } |
54 outputElement.appendChild(document.createTextNode(text)); | 55 outputElement.appendChild(document.createTextNode(text)); |
55 outputElement.appendChild(document.createElement("br")); | 56 outputElement.appendChild(document.createElement("br")); |
56 } | 57 } |
57 | 58 |
58 function closeTest() | 59 function closeTest() |
59 { | 60 { |
60 window.internals.closeDummyInspectorFrontend(); | 61 closeInspector(); |
61 testRunner.notifyDone(); | 62 testRunner.notifyDone(); |
62 } | 63 } |
63 | 64 |
64 function runTest() | 65 function runTest() |
65 { | 66 { |
66 if (!window.testRunner) { | 67 if (!window.testRunner) { |
67 console.error("This test requires DumpRenderTree"); | 68 console.error("This test requires DumpRenderTree"); |
68 return; | 69 return; |
69 } | 70 } |
70 testRunner.dumpAsText(); | 71 testRunner.dumpAsText(); |
71 testRunner.waitUntilDone(); | 72 testRunner.waitUntilDone(); |
72 testRunner.setCanOpenWindows(true); | 73 testRunner.setCanOpenWindows(true); |
73 | 74 |
| 75 openInspector(); |
| 76 } |
| 77 |
| 78 function closeInspector() |
| 79 { |
| 80 window.internals.closeDummyInspectorFrontend(); |
| 81 } |
| 82 |
| 83 function openInspector() |
| 84 { |
74 var scriptTags = document.getElementsByTagName("script"); | 85 var scriptTags = document.getElementsByTagName("script"); |
75 var scriptUrlBasePath = ""; | 86 var scriptUrlBasePath = ""; |
76 for (var i = 0; i < scriptTags.length; ++i) { | 87 for (var i = 0; i < scriptTags.length; ++i) { |
77 var index = scriptTags[i].src.lastIndexOf("/protocol-test.js"); | 88 var index = scriptTags[i].src.lastIndexOf("/protocol-test.js"); |
78 if (index > -1 ) { | 89 if (index > -1 ) { |
79 scriptUrlBasePath = scriptTags[i].src.slice(0, index); | 90 scriptUrlBasePath = scriptTags[i].src.slice(0, index); |
80 break; | 91 break; |
81 } | 92 } |
82 } | 93 } |
83 | 94 |
84 var url = scriptUrlBasePath + "/protocol-test.html"; | 95 var dummyFrontendURL = scriptUrlBasePath + "/protocol-test.html"; |
85 var inspectorFrontend = window.internals.openDummyInspectorFrontend(url); | 96 var inspectorFrontend = window.internals.openDummyInspectorFrontend(dummyFro
ntendURL); |
86 inspectorFrontend.addEventListener("load", function(event) { | 97 inspectorFrontend.addEventListener("load", function(event) { |
87 // FIXME: rename this 'test' global field across all tests. | 98 // FIXME: rename this 'test' global field across all tests. |
88 var testFunction = window.test; | 99 var testFunction = window.test; |
89 if (typeof testFunction === "function") { | 100 if (typeof testFunction === "function") { |
90 var initializers = ""; | 101 var initializers = ""; |
91 for (var symbol in window) { | 102 for (var symbol in window) { |
92 if (!/^initialize_/.test(symbol) || typeof window[symbol] !== "f
unction") | 103 if (!/^initialize_/.test(symbol) || typeof window[symbol] !== "f
unction") |
93 continue; | 104 continue; |
94 initializers += "(" + window[symbol].toString() + ")();\n"; | 105 initializers += "(" + window[symbol].toString() + ")();\n"; |
95 } | 106 } |
96 inspectorFrontend.postMessage(initializers + "(" + testFunction.toSt
ring() +")();", "*"); | 107 inspectorFrontend.postMessage(initializers + "(" + testFunction.toSt
ring() +")();", "*"); |
97 return; | 108 return; |
98 } | 109 } |
99 // Kill waiting process if failed to send. | 110 // Kill waiting process if failed to send. |
100 alert("Failed to send test function"); | 111 alert("Failed to send test function"); |
101 testRunner.notifyDone(); | 112 testRunner.notifyDone(); |
102 }); | 113 }); |
103 } | 114 } |
OLD | NEW |