| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <script src="../../http/tests/inspector/inspector-test.js"></script> | 2 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 3 <script src="../../http/tests/inspector/debugger-test.js"></script> | 3 <script src="../../http/tests/inspector/debugger-test.js"></script> |
| 4 | 4 |
| 5 <script type="application/dart" src="scope-variables.dart"></script> | 5 <script type="application/dart" src="scope-variables.dart"></script> |
| 6 | 6 |
| 7 <script> | 7 <script> |
| 8 | 8 |
| 9 function postMessageToDart() | 9 function postMessageToDart() |
| 10 { | 10 { |
| 11 window.postMessage('fromJS', '*'); | 11 window.postMessage('fromJS', '*'); |
| 12 } | 12 } |
| 13 | 13 |
| 14 function testFunction() { | 14 function testFunction() { |
| 15 postMessageToDart(); | 15 postMessageToDart(); |
| 16 } | 16 } |
| 17 | 17 |
| 18 function test() | 18 function test() |
| 19 { | 19 { |
| 20 var realAddResult = InspectorTest.addResult; |
| 21 // Inject name mangling for Dart more deeply in the existing JS test |
| 22 // framework to reduce the amount of code that we need to duplicate from |
| 23 // the JS side. |
| 24 InspectorTest.addResult = function(text) { |
| 25 text = text.replace(/(file:\/\/\/\w):/g, "$1"); |
| 26 text = text.replace(/file:\/\/\/?[^: )]*([.]dart|[$]script|[$]trampoline
)/g, "(SOURCE_LOCATION)"); |
| 27 text = text.replace(/\(file:\/\/\/?[^)]*\)/g, "(SOURCE_LOCATION)"); |
| 28 text = text.replace(/@\d+/g, "(VM_PRIVATE_MANGLING)"); |
| 29 text = text.replace(/\$main\-[0-9]*/g, "(DEFAULT_ISOLATE_NAME_SUFFIX)"); |
| 30 text = text.replace(/:\d\d\d+/g, ":xxxx"); |
| 31 return realAddResult.call(this, text); |
| 32 }; |
| 33 |
| 20 var panel = WebInspector.inspectorView.showPanel("sources"); | 34 var panel = WebInspector.inspectorView.showPanel("sources"); |
| 21 InspectorTest.runDebuggerTestSuite([ | 35 InspectorTest.runDebuggerTestSuite([ |
| 22 function testScopeChain(next) | 36 function testScopeChain(next) |
| 23 { | 37 { |
| 24 InspectorTest.showScriptSource('scope-variables.dart', didShowScript
Source); | 38 InspectorTest.showScriptSource('scope-variables.dart', didShowScript
Source); |
| 25 | 39 |
| 26 function didShowScriptSource(sourceFrame) | 40 function didShowScriptSource(sourceFrame) |
| 27 { | 41 { |
| 28 setBreakpointAndWaitUntilPaused(sourceFrame, 23, didPauseInDart)
; | 42 setBreakpointAndWaitUntilPaused(sourceFrame, 23, didPauseInDart)
; |
| 29 InspectorTest.runTestFunction(); | 43 InspectorTest.runTestFunction(); |
| 30 } | 44 } |
| 31 | 45 |
| 32 function didPauseInDart(callFrames) | 46 function didPauseInDart(callFrames) |
| 33 { | 47 { |
| 34 InspectorTest.captureStackTrace(callFrames); | 48 InspectorTest.captureStackTrace(callFrames); |
| 35 expandScopeChainSections(); | 49 expandScopeChainSections(); |
| 36 InspectorTest.runAfterPendingDispatches(didExpandScopeChainSecti
ons); | 50 InspectorTest.runAfterPendingDispatches(didExpandScopeChainSecti
ons); |
| 37 } | 51 } |
| 38 | 52 |
| 39 function didExpandScopeChainSections() | 53 function didExpandScopeChainSections() |
| 40 { | 54 { |
| 41 dumpScopeChainContents(); | 55 InspectorTest.dumpScopeVariablesSidebarPane(); |
| 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); | 56 InspectorTest.resumeExecution(next); |
| 69 } | 57 } |
| 70 } | 58 } |
| 71 ]); | 59 ]); |
| 72 | 60 |
| 73 function expandScopeChainSections() | 61 function expandScopeChainSections() |
| 74 { | 62 { |
| 75 var sections = WebInspector.inspectorView.currentPanel().sidebarPanes.sc
opechain._sections; | 63 var sections = WebInspector.inspectorView.currentPanel().sidebarPanes.sc
opechain._sections; |
| 76 for (var i = 0; i < sections.length; i++) | 64 for (var i = 0; i < sections.length; i++) |
| 77 sections[i].expand(); | 65 sections[i].expand(); |
| 78 } | 66 } |
| 79 | 67 |
| 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) | 68 function setBreakpointAndWaitUntilPaused(sourceFrame, lineNumber, pausedCall
back) |
| 99 { | 69 { |
| 100 var expectedBreakpointId; | 70 var expectedBreakpointId; |
| 101 InspectorTest.addSniffer(WebInspector.BreakpointManager.TargetBreakpoint
.prototype, "_didSetBreakpointInDebugger", didSetBreakpointInDebugger); | 71 InspectorTest.addSniffer(WebInspector.BreakpointManager.TargetBreakpoint
.prototype, "_didSetBreakpointInDebugger", didSetBreakpointInDebugger); |
| 102 InspectorTest.setBreakpoint(sourceFrame, lineNumber, "", true); | 72 InspectorTest.setBreakpoint(sourceFrame, lineNumber, "", true); |
| 103 | 73 |
| 104 function didSetBreakpointInDebugger(callback, breakpointId) | 74 function didSetBreakpointInDebugger(callback, breakpointId) |
| 105 { | 75 { |
| 106 expectedBreakpointId = breakpointId; | 76 expectedBreakpointId = breakpointId; |
| 107 InspectorTest.waitUntilPaused(didPause); | 77 InspectorTest.waitUntilPaused(didPause); |
| 108 } | 78 } |
| 109 | 79 |
| 110 function didPause(callFrames, reason, breakpointIds) | 80 function didPause(callFrames, reason, breakpointIds) |
| 111 { | 81 { |
| 112 InspectorTest.assertEquals(breakpointIds.length, 1); | 82 InspectorTest.assertEquals(breakpointIds.length, 1); |
| 113 InspectorTest.assertEquals(breakpointIds[0], expectedBreakpointId); | 83 InspectorTest.assertEquals(breakpointIds[0], expectedBreakpointId); |
| 114 InspectorTest.assertEquals(reason, "other"); | 84 InspectorTest.assertEquals(reason, "other"); |
| 115 | 85 |
| 116 pausedCallback(callFrames); | 86 pausedCallback(callFrames); |
| 117 } | 87 } |
| 118 } | 88 } |
| 119 }; | 89 }; |
| 120 </script> | 90 </script> |
| 121 | 91 |
| 122 <body onload="runTest()"> | 92 <body onload="runTest()"> |
| 123 <div id="example_div">Example div</div> | 93 <div id="example_div">Example div</div> |
| 124 </body> | 94 </body> |
| 125 </html> | 95 </html> |
| OLD | NEW |