| Index: LayoutTests/dart/inspector/evaluate-in-console.html
|
| diff --git a/LayoutTests/dart/inspector/evaluate-in-console.html b/LayoutTests/dart/inspector/evaluate-in-console.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..62bf68d5cf694f3c452fcf7f2c01547ab56d8860
|
| --- /dev/null
|
| +++ b/LayoutTests/dart/inspector/evaluate-in-console.html
|
| @@ -0,0 +1,136 @@
|
| +<html>
|
| +<script src="../../http/tests/inspector/inspector-test.js"></script>
|
| +<script src="../../http/tests/inspector/debugger-test.js"></script>
|
| +
|
| +<script type="application/dart" src="evaluate-in-console.dart"></script>
|
| +
|
| +<script>
|
| +function postMessageToDart()
|
| +{
|
| + window.postMessage('fromJS', '*');
|
| +}
|
| +
|
| +function testFunction() {
|
| + postMessageToDart();
|
| +}
|
| +
|
| +function test()
|
| +{
|
| + var panel = WebInspector.inspectorView.showPanel("sources");
|
| + InspectorTest.runDebuggerTestSuite([
|
| + function testScopeChain(next)
|
| + {
|
| + InspectorTest.showScriptSource('evaluate-in-console.dart', didShowScriptSource);
|
| +
|
| + function didShowScriptSource(sourceFrame)
|
| + {
|
| + setBreakpointAndWaitUntilPaused(sourceFrame, 12, didPauseInDart);
|
| + InspectorTest.runTestFunction();
|
| + }
|
| +
|
| + function didPauseInDart(callFrames)
|
| + {
|
| + InspectorTest.captureStackTrace(callFrames);
|
| +
|
| + function evaluate(expression)
|
| + {
|
| + InspectorTest.evaluateInConsole(expression, didEvaluateInConsole);
|
| + function didEvaluateInConsole(result)
|
| + {
|
| + // For file urls we leave the file name and line #
|
| + // information in the url as these file urls are from
|
| + // the test files themselves so will not be broken by
|
| + // external changes.
|
| + result = result.replace(/\(file:[^.)]*(\/[^\/]*[.]dart[0-9:]*)\)/g,
|
| + "(FILE_SOURCE_LOCATION$1)");
|
| + // For dart: urls we remove all file name and line #
|
| + // information as the tests shouldn't break when
|
| + // dart:core changes.
|
| + result = result.replace(/\(dart:[^)]*\)/g,
|
| + "(DART_CORE_LIBRARY_SOURCE_LOCATION)");
|
| + InspectorTest.addResult(expression + " = " + result);
|
| + if (expressions.length)
|
| + evaluate(expressions.shift());
|
| + else
|
| + next();
|
| + }
|
| + }
|
| +
|
| + var expressions = [
|
| + // Instance fields and methods.
|
| + 'test.instanceField',
|
| + 'test.instanceField = "new value"',
|
| + 'test.foo',
|
| + 'test.foo = 3',
|
| + 'test.foo',
|
| + 'test.somePropertyThatDoesntExist',
|
| + 'test.toString()',
|
| + 'test.toString(1)',
|
| + 'test.create("x").instanceField',
|
| + 'test.concat(test.create("x"), test.create("y"))',
|
| + // Local variables and functions.
|
| + '_private',
|
| + // Global fields and functions.
|
| + 'globalField',
|
| + 'calculateSquareRoot(25)',
|
| + 'new Element.tag("div").outerHtml',
|
| + '(new Element.tag("div")..append(new Element.tag("h1"))).outerHtml',
|
| + 'new Element.tag("div").tagName',
|
| + 'intList.toString()',
|
| + '(LinkedList).toString()',
|
| + 'var a=new List<int>()..add(4)..add(42)',
|
| + 'a.toString()',
|
| + '$consoleVariables.variables()',
|
| + 'var f = (x) => x*42',
|
| + 'f(2)',
|
| + '[] is List',
|
| + '{} is List',
|
| + '"This should be an int: ${10000000000000000000000 - 1}"',
|
| + '10000000000000000000000 is int',
|
| + '1.0 is int',
|
| + '1.0 is double',
|
| + '((x) => x * 2)(21)',
|
| + '((x) { var z = x * 4; return z; })(21)',
|
| + 'print("Hello $window")',
|
| + ];
|
| + evaluate(expressions.shift());
|
| + }
|
| + },
|
| +
|
| + function testPrint(next)
|
| + {
|
| + // This shouldn't crash.
|
| + InspectorTest.evaluateInConsole('print("foo")', function()
|
| + {
|
| + InspectorTest.resumeExecution(next);
|
| + });
|
| + }
|
| + ]);
|
| +
|
| + function setBreakpointAndWaitUntilPaused(sourceFrame, lineNumber, pausedCallback)
|
| + {
|
| + var expectedBreakpointId;
|
| + InspectorTest.addSniffer(WebInspector.BreakpointManager.TargetBreakpoint.prototype, "_didSetBreakpointInDebugger", didSetBreakpointInDebugger);
|
| + InspectorTest.setBreakpoint(sourceFrame, lineNumber, "", true);
|
| +
|
| + function didSetBreakpointInDebugger(callback, breakpointId)
|
| + {
|
| + expectedBreakpointId = breakpointId;
|
| + InspectorTest.waitUntilPaused(didPause);
|
| + }
|
| +
|
| + function didPause(callFrames, reason, breakpointIds)
|
| + {
|
| + InspectorTest.assertEquals(breakpointIds.length, 1);
|
| + InspectorTest.assertEquals(breakpointIds[0], expectedBreakpointId);
|
| + InspectorTest.assertEquals(reason, "other");
|
| +
|
| + pausedCallback(callFrames);
|
| + }
|
| + }
|
| +};
|
| +</script>
|
| +
|
| +<body onload="runTest()">
|
| +</body>
|
| +</html>
|
|
|