OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Samsung Electronics. All rights reserved. | 2 * Copyright (C) 2012 Samsung Electronics. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 outputElement.appendChild(document.createTextNode(text)); | 65 outputElement.appendChild(document.createTextNode(text)); |
66 outputElement.appendChild(document.createElement("br")); | 66 outputElement.appendChild(document.createElement("br")); |
67 } | 67 } |
68 | 68 |
69 function closeTest() | 69 function closeTest() |
70 { | 70 { |
71 closeInspector(); | 71 closeInspector(); |
72 testRunner.notifyDone(); | 72 testRunner.notifyDone(); |
73 } | 73 } |
74 | 74 |
| 75 var reloadParam = "__protocol__test__reload__"; |
| 76 |
75 function runTest() | 77 function runTest() |
76 { | 78 { |
77 if (!window.testRunner) { | 79 if (!window.testRunner) { |
78 console.error("This test requires DumpRenderTree"); | 80 console.error("This test requires DumpRenderTree"); |
79 return; | 81 return; |
80 } | 82 } |
| 83 |
| 84 var reloadIndex = window.location.href.lastIndexOf(reloadParam); |
| 85 if (reloadIndex !== -1) { |
| 86 var lastId = window.location.href.substring(reloadIndex + reloadParam.le
ngth); |
| 87 window.lastFrontendEvalId = parseInt(lastId, 10); |
| 88 evaluateInFrontend("InspectorTest.pageReloaded();"); |
| 89 return; |
| 90 } |
| 91 |
81 testRunner.dumpAsText(); | 92 testRunner.dumpAsText(); |
82 testRunner.waitUntilDone(); | 93 testRunner.waitUntilDone(); |
83 testRunner.setCanOpenWindows(true); | 94 testRunner.setCanOpenWindows(true); |
84 | 95 |
85 openInspector(); | 96 openInspector(); |
86 } | 97 } |
87 | 98 |
88 function closeInspector() | 99 function closeInspector() |
89 { | 100 { |
90 testRunner.closeWebInspector(); | 101 testRunner.closeWebInspector(); |
91 } | 102 } |
92 | 103 |
93 var lastFrontendEvalId = 0; | 104 var lastFrontendEvalId = 0; |
94 function evaluateInFrontend(script) | 105 function evaluateInFrontend(script) |
95 { | 106 { |
96 testRunner.evaluateInWebInspector(++lastFrontendEvalId, script); | 107 testRunner.evaluateInWebInspector(++lastFrontendEvalId, script); |
97 } | 108 } |
98 | 109 |
| 110 function navigateProtocolTest(url) |
| 111 { |
| 112 url += (url.indexOf("?") === -1 ? "?" : "&") + reloadParam + lastFrontendEva
lId; |
| 113 window.location.replace(url); |
| 114 } |
| 115 |
99 function openInspector() | 116 function openInspector() |
100 { | 117 { |
101 var scriptTags = document.getElementsByTagName("script"); | 118 var scriptTags = document.getElementsByTagName("script"); |
102 var scriptUrlBasePath = ""; | 119 var scriptUrlBasePath = ""; |
103 for (var i = 0; i < scriptTags.length; ++i) { | 120 for (var i = 0; i < scriptTags.length; ++i) { |
104 var index = scriptTags[i].src.lastIndexOf("/inspector-protocol-test.js")
; | 121 var index = scriptTags[i].src.lastIndexOf("/inspector-protocol-test.js")
; |
105 if (index > -1 ) { | 122 if (index > -1 ) { |
106 scriptUrlBasePath = scriptTags[i].src.slice(0, index); | 123 scriptUrlBasePath = scriptTags[i].src.slice(0, index); |
107 break; | 124 break; |
108 } | 125 } |
(...skipping 10 matching lines...) Expand all Loading... |
119 continue; | 136 continue; |
120 initializers += "(" + window[symbol].toString() + ")();\n"; | 137 initializers += "(" + window[symbol].toString() + ")();\n"; |
121 } | 138 } |
122 evaluateInFrontend(initializers + "(" + testFunction.toString() +")();")
; | 139 evaluateInFrontend(initializers + "(" + testFunction.toString() +")();")
; |
123 return; | 140 return; |
124 } | 141 } |
125 // Kill waiting process if failed to send. | 142 // Kill waiting process if failed to send. |
126 alert("Failed to send test function"); | 143 alert("Failed to send test function"); |
127 testRunner.notifyDone(); | 144 testRunner.notifyDone(); |
128 } | 145 } |
OLD | NEW |