| // Copyright 2017 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| (async function() { |
| TestRunner.addResult(`Test that evaluation on call frame works across all inspected windows in the call stack.\n`); |
| await TestRunner.loadModule('console_test_runner'); |
| await TestRunner.loadModule('sources_test_runner'); |
| await TestRunner.showPanel('sources'); |
| await TestRunner.loadHTML(` |
| <iframe id="iframe"></iframe> |
| `); |
| await TestRunner.evaluateInPagePromise(` |
| function dirxml() { return "overridden dirxml() in top frame"; } |
| |
| var iframe = document.getElementById("iframe"); |
| var doc = iframe.contentWindow.document; |
| |
| var html = "<html><head><script>\\n" + |
| "function dir() { return 'overridden dir() in iframe'; }\\n" + |
| "function pauseInsideIframe()\\n" + |
| "{\\n" + |
| " var table = 'local in iframe';\\n" + |
| " debugger;\\n" + |
| " dir;\\n" + |
| "}\\n" + |
| "</" + "script></" + "head><" + "body></" + "body></" + "html>"; |
| doc.open(); |
| doc.write(html); |
| doc.close(); |
| function testFunction() |
| { |
| var clear = "local in top frame"; |
| var iframe = document.getElementById("iframe"); |
| iframe.contentWindow.pauseInsideIframe.call({foo: 42}); |
| } |
| `); |
| |
| var expressions = [ |
| 'dir()', 'dirxml()', 'table', 'clear', |
| 'x:', // print correct syntax error: crbug.com/110163 |
| ]; |
| |
| function evaluateInConsoleAndDump(callback) { |
| var copy = expressions.slice(); |
| inner(); |
| |
| function inner() { |
| var expression = copy.shift(); |
| if (expression) |
| ConsoleTestRunner.evaluateInConsoleAndDump(expression, inner, true); |
| else |
| callback(); |
| } |
| } |
| |
| SourcesTestRunner.startDebuggerTest(step1, true); |
| |
| function step1() { |
| SourcesTestRunner.runTestFunctionAndWaitUntilPaused(step2); |
| } |
| |
| async function step2(callFrames) { |
| await TestRunner.addSnifferPromise(Sources.CallStackSidebarPane.prototype, '_updatedForTest'); |
| await SourcesTestRunner.captureStackTrace(callFrames); |
| TestRunner.addResult('\n=== Evaluating on iframe ==='); |
| evaluateInConsoleAndDump(step3); |
| } |
| |
| function step3() { |
| var pane = self.runtime.sharedInstance(Sources.CallStackSidebarPane); |
| pane._selectNextCallFrameOnStack(); |
| TestRunner.deprecatedRunAfterPendingDispatches(step4); |
| } |
| |
| function step4() { |
| TestRunner.addResult('\n=== Evaluating on top frame ==='); |
| evaluateInConsoleAndDump(step5); |
| } |
| |
| function step5() { |
| SourcesTestRunner.completeDebuggerTest(); |
| } |
| })(); |