Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-command-line-api-can-be-overriden.html

Issue 2030453002: [DevTools] Support CommandLineAPI in workers and Node.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-command-line-api-can-be-overriden.html
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-command-line-api-can-be-overriden.html b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-command-line-api-can-be-overriden.html
new file mode 100644
index 0000000000000000000000000000000000000000..c74afd74269f4f5edf7f55e255e61780051de343
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-command-line-api-can-be-overriden.html
@@ -0,0 +1,78 @@
+<html>
+<head>
+<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
+<script>
+
+function overrideDir()
+{
+ var v = "" + dir;
+ dir = 239;
+ return v + " -> " + dir;
+}
+
+function override$_()
+{
+ var v = "" + $_;
+ $_ = 239;
+ return v + " -> " + $_;
+}
+
+function doesCommandLineAPIEnumerable()
+{
+ for (var v in window) {
+ if (v === "dir" || v === "$_")
+ return "enumerable";
+ }
+ return "non enumerable";
+}
+
+function test()
+{
+ function evaluatePromise(expression)
+ {
+ var cb;
+ var p = new Promise(resolver => cb = resolver);
+ InspectorTest.sendCommandOrDie("Runtime.evaluate", { "expression": expression, objectGroup: "console", includeCommandLineAPI: true }, cb);
+ return p;
+ }
+
+ evaluatePromise("doesCommandLineAPIEnumerable()")
+ .then(dumpResult.bind(null, "Check that CommandLineAPI isn't enumerable on window object:"))
+ .then(() => evaluatePromise("overrideDir()"))
+ .then(dumpResult.bind(null, "Override dir:"))
+ .then(() => evaluatePromise("\"\" + dir"))
+ .then(dumpResult.bind(null, "CommandLineAPI doesn't override dir:"))
+ .then(() => evaluatePromise("delete dir"))
+ .then(() => evaluatePromise("overrideDir()"))
+ .then(dumpResult.bind(null, "CommandLineAPI is presented after removing override variable:"))
+ // set $_ to 42
+ .then(() => evaluatePromise("42"))
+ .then(() => evaluatePromise("override$_()"))
+ .then(dumpResult.bind(null, "Override $_:"))
+ .then(() => evaluatePromise("\"\" + $_"))
+ .then(dumpResult.bind(null, "CommandLineAPI doesn't override $_:"))
+ .then(() => evaluatePromise("delete $_"))
+ .then(() => evaluatePromise("override$_()"))
+ .then(dumpResult.bind(null, "CommandLineAPI is presented after removing override variable:"))
+ .then(() => evaluatePromise("var dir = 1; \"\" + dir"))
+ .then(dumpResult.bind(null, "CommandLineAPI can be overridden by var dir = 1:"))
+ .then(() => evaluatePromise("\"\" + dir"))
+ .then(dumpResult.bind(null, "CommandLineAPI doesn't override var dir = 1:"))
+ .then(() => evaluatePromise("Object.defineProperty(window, \"copy\", { get: () => 239 }); \"\" + copy"))
+ .then(dumpResult.bind(null, "CommandLineAPI can be overridden by Object.defineProperty:"))
+ .then(() => evaluatePromise("\"\" + copy"))
+ .then(dumpResult.bind(null, "CommandLineAPI doesn't override Object.defineProperty:"))
+ .then(() => InspectorTest.completeTest());
+
+ function dumpResult(title, message)
+ {
+ InspectorTest.log(title);
+ InspectorTest.log(message.result.value);
+ }
+}
+</script>
+</head>
+<body onLoad="runTest();">
+Tests that Command Line API doesn't override defined on window methods and can be overridden during evaluation.
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698