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="evaluate-in-console.dart"></script> |
| 6 |
| 7 <script> |
| 8 function postMessageToDart() |
| 9 { |
| 10 window.postMessage('fromJS', '*'); |
| 11 } |
| 12 |
| 13 function testFunction() { |
| 14 postMessageToDart(); |
| 15 } |
| 16 |
| 17 function test() |
| 18 { |
| 19 var panel = WebInspector.inspectorView.showPanel("sources"); |
| 20 InspectorTest.runDebuggerTestSuite([ |
| 21 function testScopeChain(next) |
| 22 { |
| 23 InspectorTest.showScriptSource('evaluate-in-console.dart', didShowSc
riptSource); |
| 24 |
| 25 function didShowScriptSource(sourceFrame) |
| 26 { |
| 27 setBreakpointAndWaitUntilPaused(sourceFrame, 12, didPauseInDart)
; |
| 28 InspectorTest.runTestFunction(); |
| 29 } |
| 30 |
| 31 function didPauseInDart(callFrames) |
| 32 { |
| 33 InspectorTest.captureStackTrace(callFrames); |
| 34 |
| 35 function evaluate(expression) |
| 36 { |
| 37 InspectorTest.evaluateInConsole(expression, didEvaluateInCon
sole); |
| 38 function didEvaluateInConsole(result) |
| 39 { |
| 40 // For file urls we leave the file name and line # |
| 41 // information in the url as these file urls are from |
| 42 // the test files themselves so will not be broken by |
| 43 // external changes. |
| 44 result = result.replace(/\(file:[^.)]*(\/[^\/]*[.]dart[0
-9:]*)\)/g, |
| 45 "(FILE_SOURCE_LOCATION$1)"); |
| 46 // For dart: urls we remove all file name and line # |
| 47 // information as the tests shouldn't break when |
| 48 // dart:core changes. |
| 49 result = result.replace(/\(dart:[^)]*\)/g, |
| 50 "(DART_CORE_LIBRARY_SOURCE_LOCAT
ION)"); |
| 51 InspectorTest.addResult(expression + " = " + result); |
| 52 if (expressions.length) |
| 53 evaluate(expressions.shift()); |
| 54 else |
| 55 next(); |
| 56 } |
| 57 } |
| 58 |
| 59 var expressions = [ |
| 60 // Instance fields and methods. |
| 61 'test.instanceField', |
| 62 'test.instanceField = "new value"', |
| 63 'test.foo', |
| 64 'test.foo = 3', |
| 65 'test.foo', |
| 66 'test.somePropertyThatDoesntExist', |
| 67 'test.toString()', |
| 68 'test.toString(1)', |
| 69 'test.create("x").instanceField', |
| 70 'test.concat(test.create("x"), test.create("y"))', |
| 71 // Local variables and functions. |
| 72 '_private', |
| 73 // Global fields and functions. |
| 74 'globalField', |
| 75 'calculateSquareRoot(25)', |
| 76 'new Element.tag("div").outerHtml', |
| 77 '(new Element.tag("div")..append(new Element.tag("h1"))).out
erHtml', |
| 78 'new Element.tag("div").tagName', |
| 79 'intList.toString()', |
| 80 '(LinkedList).toString()', |
| 81 'var a=new List<int>()..add(4)..add(42)', |
| 82 'a.toString()', |
| 83 '$consoleVariables.variables()', |
| 84 'var f = (x) => x*42', |
| 85 'f(2)', |
| 86 '[] is List', |
| 87 '{} is List', |
| 88 '"This should be an int: ${10000000000000000000000 - 1}"', |
| 89 '10000000000000000000000 is int', |
| 90 '1.0 is int', |
| 91 '1.0 is double', |
| 92 '((x) => x * 2)(21)', |
| 93 '((x) { var z = x * 4; return z; })(21)', |
| 94 'print("Hello $window")', |
| 95 ]; |
| 96 evaluate(expressions.shift()); |
| 97 } |
| 98 }, |
| 99 |
| 100 function testPrint(next) |
| 101 { |
| 102 // This shouldn't crash. |
| 103 InspectorTest.evaluateInConsole('print("foo")', function() |
| 104 { |
| 105 InspectorTest.resumeExecution(next); |
| 106 }); |
| 107 } |
| 108 ]); |
| 109 |
| 110 function setBreakpointAndWaitUntilPaused(sourceFrame, lineNumber, pausedCall
back) |
| 111 { |
| 112 var expectedBreakpointId; |
| 113 InspectorTest.addSniffer(WebInspector.BreakpointManager.TargetBreakpoint
.prototype, "_didSetBreakpointInDebugger", didSetBreakpointInDebugger); |
| 114 InspectorTest.setBreakpoint(sourceFrame, lineNumber, "", true); |
| 115 |
| 116 function didSetBreakpointInDebugger(callback, breakpointId) |
| 117 { |
| 118 expectedBreakpointId = breakpointId; |
| 119 InspectorTest.waitUntilPaused(didPause); |
| 120 } |
| 121 |
| 122 function didPause(callFrames, reason, breakpointIds) |
| 123 { |
| 124 InspectorTest.assertEquals(breakpointIds.length, 1); |
| 125 InspectorTest.assertEquals(breakpointIds[0], expectedBreakpointId); |
| 126 InspectorTest.assertEquals(reason, "other"); |
| 127 |
| 128 pausedCallback(callFrames); |
| 129 } |
| 130 } |
| 131 }; |
| 132 </script> |
| 133 |
| 134 <body onload="runTest()"> |
| 135 </body> |
| 136 </html> |
OLD | NEW |