OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 3 <script src="../../http/tests/inspector/debugger-test.js"></script> |
| 4 |
| 5 <script type="application/dart" src="scope-variables.dart"></script> |
| 6 |
| 7 <script> |
| 8 |
| 9 function postMessageToDart() |
| 10 { |
| 11 window.postMessage('fromJS', '*'); |
| 12 } |
| 13 |
| 14 function testFunction() { |
| 15 postMessageToDart(); |
| 16 } |
| 17 |
| 18 function test() |
| 19 { |
| 20 var panel = WebInspector.inspectorView.showPanel("sources"); |
| 21 InspectorTest.runDebuggerTestSuite([ |
| 22 function testScopeChain(next) |
| 23 { |
| 24 InspectorTest.showScriptSource('scope-variables.dart', didShowScript
Source); |
| 25 |
| 26 function didShowScriptSource(sourceFrame) |
| 27 { |
| 28 setBreakpointAndWaitUntilPaused(sourceFrame, 23, didPauseInDart)
; |
| 29 InspectorTest.runTestFunction(); |
| 30 } |
| 31 |
| 32 function didPauseInDart(callFrames) |
| 33 { |
| 34 InspectorTest.captureStackTrace(callFrames); |
| 35 expandScopeChainSections(); |
| 36 InspectorTest.runAfterPendingDispatches(didExpandScopeChainSecti
ons); |
| 37 } |
| 38 |
| 39 function didExpandScopeChainSections() |
| 40 { |
| 41 dumpScopeChainContents(); |
| 42 var sections = WebInspector.inspectorView.currentPanel().sidebar
Panes.scopechain._sections; |
| 43 for (var s = 0; s < sections.length; s++) { |
| 44 var section = sections[s]; |
| 45 |
| 46 var properties = section.propertiesForTest; |
| 47 for (var i = 0; i < properties.length; ++i) { |
| 48 if (properties[i].name == 'a1') { |
| 49 var objectId = properties[i].value._objectId; |
| 50 RuntimeAgent.callFunctionOn(objectId, "(){return thi
s.toString();}", [], undefined, didCallFunctionOn); |
| 51 RuntimeAgent.callFunctionOn(objectId, "function(){re
turn this.toString();}", [], undefined, didCallInvalidFunctionOn); |
| 52 break; |
| 53 } |
| 54 } |
| 55 if (!section.expanded) |
| 56 InspectorTest.addResult(" <section collapsed>"); |
| 57 } |
| 58 } |
| 59 |
| 60 function didCallFunctionOn(error, result, wasThrown) |
| 61 { |
| 62 InspectorTest.addResult("Inspected value toString(): " + result.
value); |
| 63 InspectorTest.resumeExecution(next); |
| 64 } |
| 65 function didCallInvalidFunctionOn(error, result, wasThrown) |
| 66 { |
| 67 InspectorTest.addResult("Result of calling invalid function. val
ue: " + result.value + ". exception thrown: " + wasThrown); |
| 68 InspectorTest.resumeExecution(next); |
| 69 } |
| 70 } |
| 71 ]); |
| 72 |
| 73 function expandScopeChainSections() |
| 74 { |
| 75 var sections = WebInspector.inspectorView.currentPanel().sidebarPanes.sc
opechain._sections; |
| 76 for (var i = 0; i < sections.length; i++) |
| 77 sections[i].expand(); |
| 78 } |
| 79 |
| 80 function dumpScopeChainContents() |
| 81 { |
| 82 var sections = WebInspector.inspectorView.currentPanel().sidebarPanes.sc
opechain._sections; |
| 83 InspectorTest.addResult(""); |
| 84 InspectorTest.addResult("Dump scope sections:"); |
| 85 for (var i = 0; i < sections.length; i++) { |
| 86 var section = sections[i]; |
| 87 var properties = section.propertiesForTest; |
| 88 var contents = InspectorTest.textContentWithLineBreaks(section.eleme
nt); |
| 89 contents = contents.replace(/(file:\/\/\/\w):/g, "$1"); |
| 90 contents = contents.replace(/file:\/\/\/?[^: )]*([.]dart|[$]script|[
$]trampoline)/g, "(SOURCE_LOCATION)"); |
| 91 contents = contents.replace(/\(file:\/\/\/?[^)]*\)/g, "(SOURCE_LOCAT
ION)"); |
| 92 contents = contents.replace(/@\d+/g, "(VM_PRIVATE_MANGLING)"); |
| 93 contents = contents.replace(/\$main\-[0-9]*/g, "(DEFAULT_ISOLATE_NAM
E_SUFFIX)"); |
| 94 InspectorTest.addResult(contents); |
| 95 } |
| 96 } |
| 97 |
| 98 function setBreakpointAndWaitUntilPaused(sourceFrame, lineNumber, pausedCall
back) |
| 99 { |
| 100 var expectedBreakpointId; |
| 101 InspectorTest.addSniffer(WebInspector.BreakpointManager.TargetBreakpoint
.prototype, "_didSetBreakpointInDebugger", didSetBreakpointInDebugger); |
| 102 InspectorTest.setBreakpoint(sourceFrame, lineNumber, "", true); |
| 103 |
| 104 function didSetBreakpointInDebugger(callback, breakpointId) |
| 105 { |
| 106 expectedBreakpointId = breakpointId; |
| 107 InspectorTest.waitUntilPaused(didPause); |
| 108 } |
| 109 |
| 110 function didPause(callFrames, reason, breakpointIds) |
| 111 { |
| 112 InspectorTest.assertEquals(breakpointIds.length, 1); |
| 113 InspectorTest.assertEquals(breakpointIds[0], expectedBreakpointId); |
| 114 InspectorTest.assertEquals(reason, "other"); |
| 115 |
| 116 pausedCallback(callFrames); |
| 117 } |
| 118 } |
| 119 }; |
| 120 </script> |
| 121 |
| 122 <body onload="runTest()"> |
| 123 <div id="example_div">Example div</div> |
| 124 </body> |
| 125 </html> |
OLD | NEW |