Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / console / console-eval-scoped.html
blobca13df6c4583482c817edad46b0b99dbeddce090
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/console-test.js"></script>
5 <script>
7 // Used to interfere into InjectedScript._propertyDescriptors()
8 Object.prototype.get = function() { return "FAIL"; };
9 Object.prototype.set = function() { return "FAIL"; };
10 Object.prototype.value = "FAIL";
11 Object.prototype.getter = "FAIL";
12 Object.prototype.setter = "FAIL";
13 Object.prototype.isOwn = true;
14 // Used to interfere into InjectedScript.primitiveTypes
15 Object.prototype.object = true;
16 // Used to interfere into InjectedScript.getEventListeners()
17 Object.prototype.nullValue = null;
18 Object.prototype.undefValue = undefined;
20 var foo = "bar";
21 var testObj = {
22 get getter() { },
23 set setter(_) { },
24 baz: "baz"
27 function test()
29 function snippet1() {
30 (function (obj) {
31 with (obj) {
32 console.log('with: ' + a);
33 eval("console.log('eval in with: ' + a)");
35 })({ a: "Object property value" })
38 function snippet2() {
39 (function (a) { eval("console.log('eval in function: ' + a)"); })("Function parameter")
42 function bodyText(f) {
43 var text = f.toString();
44 var begin = text.indexOf("{");
45 return text.substring(begin);
48 function dumpAndClearConsoleMessages(next)
50 InspectorTest.runAfterPendingDispatches(function() {
51 InspectorTest.dumpConsoleMessages();
52 InspectorTest.consoleModel.requestClearMessages();
53 InspectorTest.runAfterPendingDispatches(next);
54 });
57 InspectorTest.runTestSuite([
58 function testSnippet1(next)
60 InspectorTest.evaluateInPage(bodyText(snippet1), dumpAndClearConsoleMessages.bind(null, next));
63 function testSnippet2(next)
65 InspectorTest.evaluateInPage(bodyText(snippet2), dumpAndClearConsoleMessages.bind(null, next));
68 function testConsoleEvalPrimitiveValue(next)
70 InspectorTest.evaluateInConsole("foo", dumpAndClearConsoleMessages.bind(null, next));
73 function testConsoleEvalObject(next)
75 InspectorTest.RuntimeAgent.evaluate("testObj", step1);
77 function step1(error, result)
79 InspectorTest.RuntimeAgent.getProperties(result.objectId, /* isOwnProperty */ true, step2);
82 function step2(error, properties)
84 for (var i = 0; i < properties.length; i++)
85 InspectorTest.dump(properties[i], { objectId: "formatAsTypeName" });
87 next();
91 function testGetEventListenersDoesNotThrow(next)
93 InspectorTest.evaluateInConsole("getEventListeners(document.body.firstChild)", dumpAndClearConsoleMessages.bind(null, next));
95 ]);
97 </script>
98 </head>
99 <body onload="runTest()">
101 Tests that evaluating 'console.log()' in the console will have access to its outer scope variables.
102 <a href="https://bugs.webkit.org/show_bug.cgi?id=60547">Bug 60547.</a>
103 </p>
104 </body>
105 </html>