From b9445bfecd9018200c7a3c51ac8af693fc2dd6a2 Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Tue, 19 Jul 2016 12:23:57 -0700 Subject: [PATCH 1/5] deps: update v8_inspector To add a LICENSE file along with the v8_inspector code, we need to pick up v8_inspector from an intermediate repository: https://github.com/pavelfeldman/v8_inspector. This repo still tracks upstream code in Blink. This roll also picks up the latest v8_inspector from upstream fixing a few issues. * Pickup commit id bc60957 from pavelfeldman/v8_inspector * Update node.gyp to adapt to the new file paths * Update the DevTools hash for the devtools frontend. Fixes: https://github.com/nodejs/node/issues/7123 Fixes: https://github.com/nodejs/node/issues/7736 Fixes: https://github.com/nodejs/node/issues/7734 PR-URL: https://github.com/nodejs/node/pull/7796 Reviewed-By: bnoordhuis - Ben Noordhuis Reviewed-By: jasnell - James M Snell --- deps/v8_inspector/.gitignore | 1 - deps/v8_inspector/.gitmodules | 0 deps/v8_inspector/README.md | 12 +- .../platform/inspector_protocol/Collections.h | 23 - .../inspector_protocol/CollectionsSTL.h | 244 -------- .../inspector_protocol/CollectionsWTF.h | 193 ------- .../v8_inspector/V8DebuggerScript.cpp | 104 ---- .../v8_inspector/public/ConsoleAPITypes.h | 47 -- .../v8_inspector/public/ConsoleTypes.h | 55 -- .../v8_inspector/public/V8ToProtocolValue.h | 17 - .../{deps => third_party}/jinja2/.gitignore | 0 .../{deps => third_party}/jinja2/.travis.yml | 0 .../{deps => third_party}/jinja2/AUTHORS | 0 .../{deps => third_party}/jinja2/CHANGES | 0 .../{deps => third_party}/jinja2/LICENSE | 62 +- .../{deps => third_party}/jinja2/MANIFEST.in | 0 .../{deps => third_party}/jinja2/Makefile | 0 .../{deps => third_party}/jinja2/README.rst | 0 .../jinja2/artwork/jinjalogo.svg | 0 .../jinja2/docs/Makefile | 0 .../jinja2/docs/_static/.ignore | 0 .../jinja2/docs/_static/jinja-small.png | Bin .../jinja2/docs/_templates/sidebarintro.html | 0 .../jinja2/docs/_templates/sidebarlogo.html | 0 .../jinja2/docs/_themes/LICENSE | 0 .../jinja2/docs/_themes/README | 0 .../jinja2/docs/_themes/jinja/layout.html | 0 .../jinja2/docs/_themes/jinja/relations.html | 0 .../docs/_themes/jinja/static/jinja.css_t | 50 +- .../jinja2/docs/_themes/jinja/theme.conf | 0 .../{deps => third_party}/jinja2/docs/api.rst | 4 +- .../jinja2/docs/cache_extension.py | 0 .../jinja2/docs/changelog.rst | 0 .../{deps => third_party}/jinja2/docs/conf.py | 0 .../jinja2/docs/contents.rst.inc | 0 .../jinja2/docs/extensions.rst | 4 +- .../{deps => third_party}/jinja2/docs/faq.rst | 0 .../jinja2/docs/index.rst | 0 .../jinja2/docs/integration.rst | 0 .../jinja2/docs/intro.rst | 2 +- .../jinja2/docs/jinjaext.py | 0 .../jinja2/docs/jinjastyle.sty | 2 +- .../jinja2/docs/latexindex.rst | 0 .../jinja2/docs/logo.pdf | Bin .../jinja2/docs/sandbox.rst | 0 .../jinja2/docs/switching.rst | 0 .../jinja2/docs/templates.rst | 10 +- .../jinja2/docs/tricks.rst | 0 .../jinja2/examples/basic/cycle.py | 0 .../jinja2/examples/basic/debugger.py | 0 .../jinja2/examples/basic/inheritance.py | 0 .../examples/basic/templates/broken.html | 0 .../examples/basic/templates/subbroken.html | 0 .../jinja2/examples/basic/test.py | 0 .../basic/test_filter_and_linestatements.py | 0 .../jinja2/examples/basic/test_loop_filter.py | 0 .../jinja2/examples/basic/translate.py | 0 .../jinja2/examples/bench.py | 0 .../jinja2/examples/profile.py | 0 .../jinja2/examples/rwbench/django/_form.html | 0 .../examples/rwbench/django/_input_field.html | 0 .../examples/rwbench/django/_textarea.html | 0 .../jinja2/examples/rwbench/django/index.html | 0 .../examples/rwbench/django/layout.html | 0 .../jinja2/examples/rwbench/djangoext.py | 0 .../examples/rwbench/genshi/helpers.html | 0 .../jinja2/examples/rwbench/genshi/index.html | 0 .../examples/rwbench/genshi/layout.html | 0 .../examples/rwbench/jinja/helpers.html | 0 .../jinja2/examples/rwbench/jinja/index.html | 0 .../jinja2/examples/rwbench/jinja/layout.html | 0 .../jinja2/examples/rwbench/mako/helpers.html | 0 .../jinja2/examples/rwbench/mako/index.html | 0 .../jinja2/examples/rwbench/mako/layout.html | 0 .../jinja2/examples/rwbench/rwbench.py | 0 .../jinja2/ext/Vim/jinja.vim | 0 .../jinja2/ext/django2jinja/django2jinja.py | 28 +- .../jinja2/ext/django2jinja/example.py | 0 .../ext/django2jinja/templates/index.html | 0 .../ext/django2jinja/templates/layout.html | 0 .../django2jinja/templates/subtemplate.html | 0 .../jinja2/ext/djangojinja2.py | 0 .../jinja2/ext/inlinegettext.py | 0 .../{deps => third_party}/jinja2/ext/jinja.el | 0 .../jinja2/jinja2/__init__.py | 0 .../jinja2/jinja2/_compat.py | 0 .../jinja2/jinja2/_stringdefs.py | 0 .../jinja2/jinja2/bccache.py | 0 .../jinja2/jinja2/compiler.py | 0 .../jinja2/jinja2/constants.py | 0 .../jinja2/jinja2/debug.py | 0 .../jinja2/jinja2/defaults.py | 0 .../jinja2/jinja2/environment.py | 0 .../jinja2/jinja2/exceptions.py | 0 .../jinja2/jinja2/ext.py | 0 .../jinja2/jinja2/filters.py | 0 .../jinja2/jinja2/lexer.py | 0 .../jinja2/jinja2/loaders.py | 0 .../jinja2/jinja2/meta.py | 0 .../jinja2/jinja2/nodes.py | 0 .../jinja2/jinja2/optimizer.py | 0 .../jinja2/jinja2/parser.py | 0 .../jinja2/jinja2/runtime.py | 0 .../jinja2/jinja2/sandbox.py | 0 .../jinja2/jinja2/tests.py | 0 .../jinja2/jinja2/utils.py | 0 .../jinja2/jinja2/visitor.py | 0 .../jinja2/scripts/jinja2-debug.py | 0 .../jinja2/scripts/make-release.py | 0 .../jinja2/scripts/pylintrc | 22 +- .../{deps => third_party}/jinja2/setup.cfg | 0 .../{deps => third_party}/jinja2/setup.py | 0 .../jinja2/tests/conftest.py | 0 .../jinja2/tests/res/__init__.py | 0 .../jinja2/tests/res/templates/broken.html | 0 .../jinja2/tests/res/templates/foo/test.html | 0 .../tests/res/templates/syntaxerror.html | 0 .../jinja2/tests/res/templates/test.html | 0 .../jinja2/tests/test_api.py | 0 .../jinja2/tests/test_bytecode_cache.py | 0 .../jinja2/tests/test_core_tags.py | 0 .../jinja2/tests/test_debug.py | 0 .../jinja2/tests/test_ext.py | 0 .../jinja2/tests/test_filters.py | 0 .../jinja2/tests/test_imports.py | 0 .../jinja2/tests/test_inheritance.py | 0 .../jinja2/tests/test_lexnparse.py | 0 .../jinja2/tests/test_loader.py | 0 .../jinja2/tests/test_regression.py | 0 .../jinja2/tests/test_security.py | 0 .../jinja2/tests/test_tests.py | 0 .../jinja2/tests/test_utils.py | 0 .../{deps => third_party}/jinja2/tox.ini | 0 .../markupsafe/.gitignore | 0 .../markupsafe/.travis.yml | 0 .../{deps => third_party}/markupsafe/AUTHORS | 0 .../{deps => third_party}/markupsafe/CHANGES | 0 .../{deps => third_party}/markupsafe/LICENSE | 0 .../markupsafe/MANIFEST.in | 0 .../{deps => third_party}/markupsafe/Makefile | 0 .../markupsafe/README.rst | 0 .../markupsafe/bench/bench_basic.py | 0 .../markupsafe/bench/bench_largestring.py | 0 .../bench/bench_long_empty_string.py | 0 .../markupsafe/bench/bench_long_suffix.py | 0 .../bench/bench_short_empty_string.py | 0 .../markupsafe/bench/runbench.py | 0 .../markupsafe/markupsafe/__init__.py | 0 .../markupsafe/markupsafe/_compat.py | 0 .../markupsafe/markupsafe/_constants.py | 0 .../markupsafe/markupsafe/_native.py | 0 .../markupsafe/markupsafe/_speedups.c | 0 .../markupsafe/markupsafe/tests.py | 0 .../{deps => third_party}/markupsafe/setup.py | 0 .../{deps => third_party}/markupsafe/tox.ini | 0 .../third_party/v8_inspector/LICENSE | 27 + .../platform/inspector_protocol/Allocator.h | 0 .../platform/inspector_protocol/Array.h | 21 +- .../inspector_protocol/BackendCallback.h | 0 .../inspector_protocol/CodeGenerator.py | 10 +- .../platform/inspector_protocol/Collections.h | 46 ++ .../inspector_protocol/DispatcherBase.cpp | 16 +- .../inspector_protocol/DispatcherBase.h | 0 .../inspector_protocol/ErrorSupport.cpp | 8 +- .../inspector_protocol/ErrorSupport.h | 7 +- .../inspector_protocol/FrontendChannel.h | 0 .../platform/inspector_protocol/Maybe.h | 2 +- .../platform/inspector_protocol/OWNERS | 0 .../platform/inspector_protocol/Object.cpp | 0 .../platform/inspector_protocol/Object.h | 0 .../platform/inspector_protocol/Parser.cpp | 6 +- .../platform/inspector_protocol/Parser.h | 0 .../inspector_protocol/ParserTest.cpp | 74 +-- .../platform/inspector_protocol/Platform.h | 0 .../platform/inspector_protocol/PlatformSTL.h | 43 +- .../platform/inspector_protocol/PlatformWTF.h | 0 .../platform/inspector_protocol/String16.h | 0 .../inspector_protocol/String16STL.cpp | 10 +- .../platform/inspector_protocol/String16STL.h | 25 +- .../inspector_protocol/String16WTF.cpp | 0 .../platform/inspector_protocol/String16WTF.h | 17 +- .../TypeBuilder_cpp.template | 4 +- .../inspector_protocol/TypeBuilder_h.template | 0 .../inspector_protocol/ValueConversions.cpp | 0 .../inspector_protocol/ValueConversions.h | 8 +- .../platform/inspector_protocol/Values.cpp | 125 ++-- .../platform/inspector_protocol/Values.h | 46 +- .../generate-inspector-protocol-version | 10 +- .../platform/v8_inspector/Atomics.h | 0 .../platform/v8_inspector/DebuggerScript.js | 21 +- .../platform/v8_inspector/InjectedScript.cpp | 40 +- .../platform/v8_inspector/InjectedScript.h | 1 - .../v8_inspector/InjectedScriptNative.cpp | 26 +- .../v8_inspector/InjectedScriptNative.h | 4 +- .../v8_inspector/InjectedScriptSource.js | 114 ++-- .../v8_inspector/InspectedContext.cpp | 0 .../platform/v8_inspector/InspectedContext.h | 2 +- .../v8_inspector/JavaScriptCallFrame.cpp | 8 +- .../v8_inspector/JavaScriptCallFrame.h | 4 +- .../platform/v8_inspector/OWNERS | 0 .../platform/v8_inspector/RemoteObjectId.cpp | 8 +- .../platform/v8_inspector/RemoteObjectId.h | 0 .../platform/v8_inspector/ScriptBreakpoint.h | 0 .../platform/v8_inspector/V8Compat.h | 2 +- .../platform/v8_inspector/V8Console.cpp | 102 ++-- .../platform/v8_inspector/V8Console.h | 0 .../v8_inspector/V8ConsoleAgentImpl.cpp | 88 +++ .../v8_inspector/V8ConsoleAgentImpl.h | 45 ++ .../v8_inspector/V8ConsoleMessage.cpp | 440 ++++++++++++++ .../platform/v8_inspector/V8ConsoleMessage.h | 110 ++++ .../v8_inspector/V8DebuggerAgentImpl.cpp | 541 +++++------------- .../v8_inspector/V8DebuggerAgentImpl.h | 40 +- .../platform/v8_inspector/V8DebuggerImpl.cpp | 494 ++++++++++++---- .../platform/v8_inspector/V8DebuggerImpl.h | 60 +- .../v8_inspector/V8DebuggerScript.cpp | 121 ++++ .../platform/v8_inspector/V8DebuggerScript.h | 33 +- .../platform/v8_inspector/V8FunctionCall.cpp | 10 +- .../platform/v8_inspector/V8FunctionCall.h | 3 +- .../v8_inspector/V8HeapProfilerAgentImpl.cpp | 29 +- .../v8_inspector/V8HeapProfilerAgentImpl.h | 0 .../v8_inspector/V8InjectedScriptHost.cpp | 35 +- .../v8_inspector/V8InjectedScriptHost.h | 2 - .../v8_inspector/V8InspectorSessionImpl.cpp | 98 ++-- .../v8_inspector/V8InspectorSessionImpl.h | 20 +- .../v8_inspector/V8InternalValueType.cpp | 72 +++ .../v8_inspector/V8InternalValueType.h | 21 + .../v8_inspector/V8ProfilerAgentImpl.cpp | 39 +- .../v8_inspector/V8ProfilerAgentImpl.h | 4 +- .../platform/v8_inspector/V8Regex.cpp | 0 .../platform/v8_inspector/V8Regex.h | 0 .../v8_inspector/V8RuntimeAgentImpl.cpp | 47 +- .../v8_inspector/V8RuntimeAgentImpl.h | 6 + .../v8_inspector/V8StackTraceImpl.cpp | 68 ++- .../platform/v8_inspector/V8StackTraceImpl.h | 19 +- .../platform/v8_inspector/V8StringUtil.cpp | 28 +- .../platform/v8_inspector/V8StringUtil.h | 3 + .../platform/v8_inspector/build/rjsmin.py | 0 .../platform/v8_inspector/build/xxd.py | 0 .../v8_inspector/debugger_script_externs.js | 8 - .../v8_inspector/injected_script_externs.js | 6 - .../v8_inspector/js_protocol-1.1.json | 0 .../platform/v8_inspector/js_protocol.json | 222 +++---- .../v8_inspector/public/V8ConsoleTypes.h | 20 + .../v8_inspector/public/V8ContentSearchUtil.h | 1 + .../v8_inspector/public/V8ContextInfo.h | 2 +- .../platform/v8_inspector/public/V8Debugger.h | 30 +- .../v8_inspector/public/V8DebuggerClient.h | 17 +- .../v8_inspector/public/V8Inspector.cpp | 15 +- .../v8_inspector/public/V8Inspector.h | 30 +- .../v8_inspector/public/V8InspectorSession.h | 31 +- .../public/V8InspectorSessionClient.h | 10 +- .../v8_inspector/public/V8StackTrace.h | 12 +- .../platform/v8_inspector/v8_inspector.gyp | 24 +- node.gyp | 7 +- src/inspector_agent.cc | 2 +- 255 files changed, 2581 insertions(+), 2049 deletions(-) delete mode 100644 deps/v8_inspector/.gitignore delete mode 100644 deps/v8_inspector/.gitmodules delete mode 100644 deps/v8_inspector/platform/inspector_protocol/Collections.h delete mode 100644 deps/v8_inspector/platform/inspector_protocol/CollectionsSTL.h delete mode 100644 deps/v8_inspector/platform/inspector_protocol/CollectionsWTF.h delete mode 100644 deps/v8_inspector/platform/v8_inspector/V8DebuggerScript.cpp delete mode 100644 deps/v8_inspector/platform/v8_inspector/public/ConsoleAPITypes.h delete mode 100644 deps/v8_inspector/platform/v8_inspector/public/ConsoleTypes.h delete mode 100644 deps/v8_inspector/platform/v8_inspector/public/V8ToProtocolValue.h rename deps/v8_inspector/{deps => third_party}/jinja2/.gitignore (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/.travis.yml (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/AUTHORS (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/CHANGES (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/LICENSE (98%) rename deps/v8_inspector/{deps => third_party}/jinja2/MANIFEST.in (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/Makefile (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/README.rst (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/artwork/jinjalogo.svg (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/Makefile (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/_static/.ignore (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/_static/jinja-small.png (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/_templates/sidebarintro.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/_templates/sidebarlogo.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/_themes/LICENSE (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/_themes/README (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/_themes/jinja/layout.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/_themes/jinja/relations.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/_themes/jinja/static/jinja.css_t (99%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/_themes/jinja/theme.conf (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/api.rst (99%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/cache_extension.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/changelog.rst (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/conf.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/contents.rst.inc (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/extensions.rst (99%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/faq.rst (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/index.rst (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/integration.rst (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/intro.rst (98%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/jinjaext.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/jinjastyle.sty (98%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/latexindex.rst (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/logo.pdf (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/sandbox.rst (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/switching.rst (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/templates.rst (99%) rename deps/v8_inspector/{deps => third_party}/jinja2/docs/tricks.rst (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/basic/cycle.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/basic/debugger.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/basic/inheritance.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/basic/templates/broken.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/basic/templates/subbroken.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/basic/test.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/basic/test_filter_and_linestatements.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/basic/test_loop_filter.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/basic/translate.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/bench.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/profile.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/django/_form.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/django/_input_field.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/django/_textarea.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/django/index.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/django/layout.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/djangoext.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/genshi/helpers.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/genshi/index.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/genshi/layout.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/jinja/helpers.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/jinja/index.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/jinja/layout.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/mako/helpers.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/mako/index.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/mako/layout.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/examples/rwbench/rwbench.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/ext/Vim/jinja.vim (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/ext/django2jinja/django2jinja.py (99%) rename deps/v8_inspector/{deps => third_party}/jinja2/ext/django2jinja/example.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/ext/django2jinja/templates/index.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/ext/django2jinja/templates/layout.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/ext/django2jinja/templates/subtemplate.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/ext/djangojinja2.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/ext/inlinegettext.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/ext/jinja.el (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/__init__.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/_compat.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/_stringdefs.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/bccache.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/compiler.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/constants.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/debug.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/defaults.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/environment.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/exceptions.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/ext.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/filters.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/lexer.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/loaders.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/meta.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/nodes.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/optimizer.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/parser.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/runtime.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/sandbox.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/tests.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/utils.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/jinja2/visitor.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/scripts/jinja2-debug.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/scripts/make-release.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/scripts/pylintrc (99%) rename deps/v8_inspector/{deps => third_party}/jinja2/setup.cfg (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/setup.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/conftest.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/res/__init__.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/res/templates/broken.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/res/templates/foo/test.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/res/templates/syntaxerror.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/res/templates/test.html (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/test_api.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/test_bytecode_cache.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/test_core_tags.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/test_debug.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/test_ext.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/test_filters.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/test_imports.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/test_inheritance.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/test_lexnparse.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/test_loader.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/test_regression.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/test_security.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/test_tests.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tests/test_utils.py (100%) rename deps/v8_inspector/{deps => third_party}/jinja2/tox.ini (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/.gitignore (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/.travis.yml (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/AUTHORS (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/CHANGES (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/LICENSE (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/MANIFEST.in (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/Makefile (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/README.rst (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/bench/bench_basic.py (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/bench/bench_largestring.py (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/bench/bench_long_empty_string.py (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/bench/bench_long_suffix.py (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/bench/bench_short_empty_string.py (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/bench/runbench.py (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/markupsafe/__init__.py (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/markupsafe/_compat.py (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/markupsafe/_constants.py (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/markupsafe/_native.py (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/markupsafe/_speedups.c (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/markupsafe/tests.py (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/setup.py (100%) rename deps/v8_inspector/{deps => third_party}/markupsafe/tox.ini (100%) create mode 100644 deps/v8_inspector/third_party/v8_inspector/LICENSE rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/Allocator.h (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/Array.h (87%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/BackendCallback.h (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/CodeGenerator.py (98%) create mode 100644 deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Collections.h rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/DispatcherBase.cpp (94%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/DispatcherBase.h (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/ErrorSupport.cpp (91%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/ErrorSupport.h (86%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/FrontendChannel.h (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/Maybe.h (98%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/OWNERS (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/Object.cpp (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/Object.h (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/Parser.cpp (98%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/Parser.h (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/ParserTest.cpp (88%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/Platform.h (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/PlatformSTL.h (90%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/PlatformWTF.h (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/String16.h (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/String16STL.cpp (98%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/String16STL.h (91%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/String16WTF.cpp (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/String16WTF.h (91%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/TypeBuilder_cpp.template (98%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/TypeBuilder_h.template (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/ValueConversions.cpp (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/ValueConversions.h (95%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/Values.cpp (72%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/Values.h (82%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/inspector_protocol/generate-inspector-protocol-version (99%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/Atomics.h (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/DebuggerScript.js (98%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/InjectedScript.cpp (92%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/InjectedScript.h (99%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/InjectedScriptNative.cpp (79%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/InjectedScriptNative.h (93%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/InjectedScriptSource.js (91%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/InspectedContext.cpp (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/InspectedContext.h (97%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/JavaScriptCallFrame.cpp (92%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/JavaScriptCallFrame.h (96%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/OWNERS (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/RemoteObjectId.cpp (85%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/RemoteObjectId.h (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/ScriptBreakpoint.h (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8Compat.h (97%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8Console.cpp (87%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8Console.h (100%) create mode 100644 deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleAgentImpl.cpp create mode 100644 deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleAgentImpl.h create mode 100644 deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleMessage.cpp create mode 100644 deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleMessage.h rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8DebuggerAgentImpl.cpp (66%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8DebuggerAgentImpl.h (82%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8DebuggerImpl.cpp (59%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8DebuggerImpl.h (69%) create mode 100644 deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.cpp rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8DebuggerScript.h (77%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8FunctionCall.cpp (92%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8FunctionCall.h (95%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp (95%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8HeapProfilerAgentImpl.h (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8InjectedScriptHost.cpp (90%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8InjectedScriptHost.h (95%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8InspectorSessionImpl.cpp (81%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8InspectorSessionImpl.h (84%) create mode 100644 deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InternalValueType.cpp create mode 100644 deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InternalValueType.h rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8ProfilerAgentImpl.cpp (90%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8ProfilerAgentImpl.h (95%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8Regex.cpp (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8Regex.h (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8RuntimeAgentImpl.cpp (89%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8RuntimeAgentImpl.h (95%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8StackTraceImpl.cpp (70%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8StackTraceImpl.h (76%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8StringUtil.cpp (90%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/V8StringUtil.h (76%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/build/rjsmin.py (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/build/xxd.py (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/debugger_script_externs.js (98%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/injected_script_externs.js (92%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/js_protocol-1.1.json (100%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/js_protocol.json (90%) create mode 100644 deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ConsoleTypes.h rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/public/V8ContentSearchUtil.h (94%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/public/V8ContextInfo.h (95%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/public/V8Debugger.h (50%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/public/V8DebuggerClient.h (73%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/public/V8Inspector.cpp (89%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/public/V8Inspector.h (73%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/public/V8InspectorSession.h (64%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/public/V8InspectorSessionClient.h (68%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/public/V8StackTrace.h (74%) rename deps/v8_inspector/{ => third_party/v8_inspector}/platform/v8_inspector/v8_inspector.gyp (90%) diff --git a/deps/v8_inspector/.gitignore b/deps/v8_inspector/.gitignore deleted file mode 100644 index 2a6b83e201c455..00000000000000 --- a/deps/v8_inspector/.gitignore +++ /dev/null @@ -1 +0,0 @@ -platform/v8_inspector/build/rjsmin.pyc diff --git a/deps/v8_inspector/.gitmodules b/deps/v8_inspector/.gitmodules deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/deps/v8_inspector/README.md b/deps/v8_inspector/README.md index e3e5e14cab4a7a..d99d25f94ce3aa 100644 --- a/deps/v8_inspector/README.md +++ b/deps/v8_inspector/README.md @@ -1,10 +1,10 @@ V8 Inspector support for Node.js ================================ -This directory is a gathering of dependencies for Node.js support for the -[Chrome Debug Protocol][https://developer.chrome.com/devtools/docs/debugger-protocol]. +This repository is an intermediate repository that gathers the dependencies for +Node.js support for the [Chrome Debug Protocol][https://developer.chrome.com/devtools/docs/debugger-protocol]. -* platform/v8_inspector: vendored from https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/platform/v8_inspector -* platform/inspector_protocol: vendored from https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/platform/inspector_protocol -* deps/jinja2: vendored from https://github.com/mitsuhiko/jinja2 -* deps/markupsafe: vendored from https://github.com/mitsuhiko/markupsafe +* third_party/v8_inspector/platform/v8_inspector: vendored from https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/platform/v8_inspector +* third_party/v8_inspector/platform/inspector_protocol: vendored from https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/platform/inspector_protocol +* third_party/jinja2: vendored from https://github.com/mitsuhiko/jinja2 +* third_party/markupsafe: vendored from https://github.com/mitsuhiko/markupsafe diff --git a/deps/v8_inspector/platform/inspector_protocol/Collections.h b/deps/v8_inspector/platform/inspector_protocol/Collections.h deleted file mode 100644 index 6309284488683e..00000000000000 --- a/deps/v8_inspector/platform/inspector_protocol/Collections.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef Collections_h -#define Collections_h - -#if V8_INSPECTOR_USE_STL -#include "platform/inspector_protocol/CollectionsSTL.h" -#else -#include "platform/inspector_protocol/CollectionsWTF.h" -#endif // V8_INSPECTOR_USE_STL - - -// Macro that returns a compile time constant with the length of an array, but gives an error if passed a non-array. -template char (&ArrayLengthHelperFunction(T (&)[Size]))[Size]; -// GCC needs some help to deduce a 0 length array. -#if defined(__GNUC__) -template char (&ArrayLengthHelperFunction(T (&)[0]))[0]; -#endif -#define PROTOCOL_ARRAY_LENGTH(array) sizeof(::ArrayLengthHelperFunction(array)) - -#endif // !defined(Collections_h) diff --git a/deps/v8_inspector/platform/inspector_protocol/CollectionsSTL.h b/deps/v8_inspector/platform/inspector_protocol/CollectionsSTL.h deleted file mode 100644 index ee99cfd8bd855b..00000000000000 --- a/deps/v8_inspector/platform/inspector_protocol/CollectionsSTL.h +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CollectionsSTL_h -#define CollectionsSTL_h - -#include "platform/inspector_protocol/Platform.h" -#include "platform/inspector_protocol/String16.h" - -#include -#include -#include - -namespace blink { -namespace protocol { - -template -class Vector { -public: - Vector() { } - Vector(size_t capacity) : m_impl(capacity) { } - typedef typename std::vector::iterator iterator; - typedef typename std::vector::const_iterator const_iterator; - - iterator begin() { return m_impl.begin(); } - iterator end() { return m_impl.end(); } - const_iterator begin() const { return m_impl.begin(); } - const_iterator end() const { return m_impl.end(); } - - void resize(size_t s) { m_impl.resize(s); } - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return !m_impl.size(); } - T& operator[](size_t i) { return at(i); } - const T& operator[](size_t i) const { return at(i); } - T& at(size_t i) { return m_impl[i]; } - const T& at(size_t i) const { return m_impl.at(i); } - T& last() { return m_impl[m_impl.size() - 1]; } - const T& last() const { return m_impl[m_impl.size() - 1]; } - void append(const T& t) { m_impl.push_back(t); } - void prepend(const T& t) { m_impl.insert(m_impl.begin(), t); } - void remove(size_t i) { m_impl.erase(m_impl.begin() + i); } - void clear() { m_impl.clear(); } - void swap(Vector& other) { m_impl.swap(other.m_impl); } - void removeLast() { m_impl.pop_back(); } - -private: - std::vector m_impl; -}; - -template -class Vector> { -public: - Vector() { } - Vector(size_t capacity) : m_impl(capacity) { } - Vector(Vector&& other) { m_impl.swap(other.m_impl); } - ~Vector() { clear(); } - - typedef typename std::vector::iterator iterator; - typedef typename std::vector::const_iterator const_iterator; - - iterator begin() { return m_impl.begin(); } - iterator end() { return m_impl.end(); } - const_iterator begin() const { return m_impl.begin(); } - const_iterator end() const { return m_impl.end(); } - - void resize(size_t s) { m_impl.resize(s); } - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return !m_impl.size(); } - T* operator[](size_t i) { return at(i); } - const T* operator[](size_t i) const { return at(i); } - T* at(size_t i) { return m_impl[i]; } - const T* at(size_t i) const { return m_impl.at(i); } - T* last() { return m_impl[m_impl.size() - 1]; } - const T* last() const { return m_impl[m_impl.size() - 1]; } - void append(std::unique_ptr t) { m_impl.push_back(t.release()); } - void prepend(std::unique_ptr t) { m_impl.insert(m_impl.begin(), t.release()); } - - void remove(size_t i) - { - delete m_impl[i]; - m_impl.erase(m_impl.begin() + i); - } - - void clear() - { - for (auto t : m_impl) - delete t; - m_impl.clear(); - } - - void swap(Vector& other) { m_impl.swap(other.m_impl); } - void swap(Vector&& other) { m_impl.swap(other.m_impl); } - void removeLast() - { - delete last(); - m_impl.pop_back(); - } - -private: - Vector(const Vector&) = delete; - Vector& operator=(const Vector&) = delete; - std::vector m_impl; -}; - -template -class HashMapIterator { -public: - HashMapIterator(const I& impl) : m_impl(impl) { } - std::pair* get() const { m_pair.first = m_impl->first; m_pair.second = &m_impl->second; return &m_pair; } - std::pair& operator*() const { return *get(); } - std::pair* operator->() const { return get(); } - - bool operator==(const HashMapIterator& other) const { return m_impl == other.m_impl; } - bool operator!=(const HashMapIterator& other) const { return m_impl != other.m_impl; } - - HashMapIterator& operator++() { ++m_impl; return *this; } - -private: - mutable std::pair m_pair; - I m_impl; -}; - -template -class HashMapIterator, I> { -public: - HashMapIterator(const I& impl) : m_impl(impl) { } - std::pair* get() const { m_pair.first = m_impl->first; m_pair.second = m_impl->second; return &m_pair; } - std::pair& operator*() const { return *get(); } - std::pair* operator->() const { return get(); } - - bool operator==(const HashMapIterator, I>& other) const { return m_impl == other.m_impl; } - bool operator!=(const HashMapIterator, I>& other) const { return m_impl != other.m_impl; } - - HashMapIterator, I>& operator++() { ++m_impl; return *this; } - -private: - mutable std::pair m_pair; - I m_impl; -}; - -template -class HashMap { -public: - HashMap() { } - ~HashMap() { } - - using iterator = HashMapIterator::iterator>; - using const_iterator = HashMapIterator::const_iterator>; - - iterator begin() { return iterator(m_impl.begin()); } - iterator end() { return iterator(m_impl.end()); } - iterator find(const K& k) { return iterator(m_impl.find(k)); } - const_iterator begin() const { return const_iterator(m_impl.begin()); } - const_iterator end() const { return const_iterator(m_impl.end()); } - const_iterator find(const K& k) const { return const_iterator(m_impl.find(k)); } - - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return !m_impl.size(); } - bool set(const K& k, const V& v) - { - bool isNew = m_impl.find(k) == m_impl.end(); - m_impl[k] = v; - return isNew; - } - bool contains(const K& k) const { return m_impl.find(k) != m_impl.end(); } - V get(const K& k) const { auto it = m_impl.find(k); return it == m_impl.end() ? V() : it->second; } - void remove(const K& k) { m_impl.erase(k); } - void clear() { m_impl.clear(); } - V take(const K& k) - { - V result = m_impl[k]; - m_impl.erase(k); - return result; - } - -private: - std::map m_impl; -}; - -template -class HashMap> { -public: - HashMap() { } - ~HashMap() { clear(); } - - using iterator = HashMapIterator, typename std::map::iterator>; - using const_iterator = HashMapIterator, typename std::map::const_iterator>; - - iterator begin() { return iterator(m_impl.begin()); } - iterator end() { return iterator(m_impl.end()); } - iterator find(const K& k) { return iterator(m_impl.find(k)); } - const_iterator begin() const { return const_iterator(m_impl.begin()); } - const_iterator end() const { return const_iterator(m_impl.end()); } - const_iterator find(const K& k) const { return const_iterator(m_impl.find(k)); } - - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return !m_impl.size(); } - bool set(const K& k, std::unique_ptr v) - { - bool isNew = m_impl.find(k) == m_impl.end(); - if (!isNew) - delete m_impl[k]; - m_impl[k] = v.release(); - return isNew; - } - bool contains(const K& k) const { return m_impl.find(k) != m_impl.end(); } - V* get(const K& k) const { auto it = m_impl.find(k); return it == m_impl.end() ? nullptr : it->second; } - std::unique_ptr take(const K& k) - { - if (!contains(k)) - return nullptr; - std::unique_ptr result(m_impl[k]); - delete m_impl[k]; - m_impl.erase(k); - return result; - } - void remove(const K& k) - { - delete m_impl[k]; - m_impl.erase(k); - } - - void clear() - { - for (auto pair : m_impl) - delete pair.second; - m_impl.clear(); - } - -private: - std::map m_impl; -}; - -template -class HashSet : public protocol::HashMap { -public: - void add(const K& k) { this->set(k, k); } -}; - -} // namespace platform -} // namespace blink - -#endif // !defined(CollectionsSTL_h) diff --git a/deps/v8_inspector/platform/inspector_protocol/CollectionsWTF.h b/deps/v8_inspector/platform/inspector_protocol/CollectionsWTF.h deleted file mode 100644 index 5d8fbf625f51b2..00000000000000 --- a/deps/v8_inspector/platform/inspector_protocol/CollectionsWTF.h +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CollectionsWTF_h -#define CollectionsWTF_h - -#include "wtf/Allocator.h" -#include "wtf/HashMap.h" -#include "wtf/PtrUtil.h" -#include "wtf/Vector.h" -#include "wtf/VectorTraits.h" - -namespace blink { -namespace protocol { - -template -class Vector { -public: - Vector() { } - Vector(size_t capacity) : m_impl(capacity) { } - typedef T* iterator; - typedef const T* const_iterator; - - iterator begin() { return m_impl.begin(); } - iterator end() { return m_impl.end(); } - const_iterator begin() const { return m_impl.begin(); } - const_iterator end() const { return m_impl.end(); } - - void resize(size_t s) { m_impl.resize(s); } - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return m_impl.isEmpty(); } - T& operator[](size_t i) { return at(i); } - const T& operator[](size_t i) const { return at(i); } - T& at(size_t i) { return m_impl.at(i); } - const T& at(size_t i) const { return m_impl.at(i); } - T& last() { return m_impl.last(); } - const T& last() const { return m_impl.last(); } - void append(const T& t) { m_impl.append(t); } - void prepend(const T& t) { m_impl.prepend(t); } - void remove(size_t i) { m_impl.remove(i); } - void clear() { m_impl.clear(); } - void swap(Vector& other) { m_impl.swap(other.m_impl); } - void removeLast() { m_impl.removeLast(); } - -private: - WTF::Vector m_impl; -}; - -template -class Vector> { - WTF_MAKE_NONCOPYABLE(Vector); -public: - Vector() { } - Vector(size_t capacity) : m_impl(capacity) { } - Vector(Vector>&& other) : m_impl(std::move(other.m_impl)) { } - ~Vector() { } - - typedef std::unique_ptr* iterator; - typedef const std::unique_ptr* const_iterator; - - iterator begin() { return m_impl.begin(); } - iterator end() { return m_impl.end(); } - const_iterator begin() const { return m_impl.begin(); } - const_iterator end() const { return m_impl.end(); } - - void resize(size_t s) { m_impl.resize(s); } - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return m_impl.isEmpty(); } - T* operator[](size_t i) { return m_impl.at(i).get(); } - const T* operator[](size_t i) const { return m_impl.at(i).get(); } - T* at(size_t i) { return m_impl.at(i).get(); } - const T* at(size_t i) const { return m_impl.at(i).get(); } - T* last() { return m_impl.last().get(); } - const T* last() const { return m_impl.last(); } - void append(std::unique_ptr t) { m_impl.append(std::move(t)); } - void prepend(std::unique_ptr t) { m_impl.prepend(std::move(t)); } - void remove(size_t i) { m_impl.remove(i); } - void clear() { m_impl.clear(); } - void swap(Vector>& other) { m_impl.swap(other.m_impl); } - void swap(Vector>&& other) { m_impl.swap(other.m_impl); } - void removeLast() { m_impl.removeLast(); } - -private: - WTF::Vector> m_impl; -}; - -template -class HashMapIterator { - STACK_ALLOCATED(); -public: - HashMapIterator(const I& impl) : m_impl(impl) { } - std::pair* get() const { m_pair = std::make_pair(m_impl->key, &m_impl->value); return &m_pair; } - std::pair& operator*() const { return *get(); } - std::pair* operator->() const { return get(); } - - bool operator==(const HashMapIterator& other) const { return m_impl == other.m_impl; } - bool operator!=(const HashMapIterator& other) const { return m_impl != other.m_impl; } - - HashMapIterator& operator++() { ++m_impl; return *this; } - -private: - mutable std::pair m_pair; - I m_impl; -}; - -template -class HashMapIterator, I> { - STACK_ALLOCATED(); -public: - HashMapIterator(const I& impl) : m_impl(impl) { } - std::pair* get() const { m_pair = std::make_pair(m_impl->key, m_impl->value.get()); return &m_pair; } - std::pair& operator*() const { return *get(); } - std::pair* operator->() const { return get(); } - - bool operator==(const HashMapIterator, I>& other) const { return m_impl == other.m_impl; } - bool operator!=(const HashMapIterator, I>& other) const { return m_impl != other.m_impl; } - - HashMapIterator, I>& operator++() { ++m_impl; return *this; } - -private: - mutable std::pair m_pair; - I m_impl; -}; - -template -class HashMap { -public: - HashMap() { } - ~HashMap() { } - - using iterator = HashMapIterator::iterator>; - using const_iterator = HashMapIterator::const_iterator>; - - iterator begin() { return iterator(m_impl.begin()); } - iterator end() { return iterator(m_impl.end()); } - iterator find(const K& k) { return iterator(m_impl.find(k)); } - const_iterator begin() const { return const_iterator(m_impl.begin()); } - const_iterator end() const { return const_iterator(m_impl.end()); } - const_iterator find(const K& k) const { return const_iterator(m_impl.find(k)); } - - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return m_impl.isEmpty(); } - bool set(const K& k, const V& v) { return m_impl.set(k, v).isNewEntry; } - bool contains(const K& k) const { return m_impl.contains(k); } - V get(const K& k) const { return m_impl.get(k); } - void remove(const K& k) { m_impl.remove(k); } - void clear() { m_impl.clear(); } - V take(const K& k) { return m_impl.take(k); } - -private: - WTF::HashMap m_impl; -}; - -template -class HashMap> { -public: - HashMap() { } - ~HashMap() { } - - using iterator = HashMapIterator, typename WTF::HashMap>::iterator>; - using const_iterator = HashMapIterator, typename WTF::HashMap>::const_iterator>; - - iterator begin() { return iterator(m_impl.begin()); } - iterator end() { return iterator(m_impl.end()); } - iterator find(const K& k) { return iterator(m_impl.find(k)); } - const_iterator begin() const { return const_iterator(m_impl.begin()); } - const_iterator end() const { return const_iterator(m_impl.end()); } - const_iterator find(const K& k) const { return const_iterator(m_impl.find(k)); } - - size_t size() const { return m_impl.size(); } - bool isEmpty() const { return m_impl.isEmpty(); } - bool set(const K& k, std::unique_ptr v) { return m_impl.set(k, std::move(v)).isNewEntry; } - bool contains(const K& k) const { return m_impl.contains(k); } - V* get(const K& k) const { return m_impl.get(k); } - std::unique_ptr take(const K& k) { return m_impl.take(k); } - void remove(const K& k) { m_impl.remove(k); } - void clear() { m_impl.clear(); } - -private: - WTF::HashMap> m_impl; -}; - -template -class HashSet : public protocol::HashMap { -public: - void add(const K& k) { this->set(k, k); } -}; - -} // namespace platform -} // namespace blink - -#endif // !defined(CollectionsWTF_h) diff --git a/deps/v8_inspector/platform/v8_inspector/V8DebuggerScript.cpp b/deps/v8_inspector/platform/v8_inspector/V8DebuggerScript.cpp deleted file mode 100644 index 14dba693e97653..00000000000000 --- a/deps/v8_inspector/platform/v8_inspector/V8DebuggerScript.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "platform/v8_inspector/V8DebuggerScript.h" - -namespace blink { - -V8DebuggerScript::V8DebuggerScript() - : m_startLine(0) - , m_startColumn(0) - , m_endLine(0) - , m_endColumn(0) - , m_executionContextId(0) - , m_isContentScript(false) - , m_isInternalScript(false) - , m_isLiveEdit(false) -{ -} - -String16 V8DebuggerScript::sourceURL() const -{ - return m_sourceURL.isEmpty() ? m_url : m_sourceURL; -} - -V8DebuggerScript& V8DebuggerScript::setURL(const String16& url) -{ - m_url = url; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setSourceURL(const String16& sourceURL) -{ - m_sourceURL = sourceURL; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setSourceMappingURL(const String16& sourceMappingURL) -{ - m_sourceMappingURL = sourceMappingURL; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setSource(const String16& source) -{ - m_source = source; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setHash(const String16& hash) -{ - m_hash = hash; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setStartLine(int startLine) -{ - m_startLine = startLine; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setStartColumn(int startColumn) -{ - m_startColumn = startColumn; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setEndLine(int endLine) -{ - m_endLine = endLine; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setEndColumn(int endColumn) -{ - m_endColumn = endColumn; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setExecutionContextId(int executionContextId) -{ - m_executionContextId = executionContextId; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setIsContentScript(bool isContentScript) -{ - m_isContentScript = isContentScript; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setIsInternalScript(bool isInternalScript) -{ - m_isInternalScript = isInternalScript; - return *this; -} - -V8DebuggerScript& V8DebuggerScript::setIsLiveEdit(bool isLiveEdit) -{ - m_isLiveEdit = isLiveEdit; - return *this; -} - -} // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/public/ConsoleAPITypes.h b/deps/v8_inspector/platform/v8_inspector/public/ConsoleAPITypes.h deleted file mode 100644 index 59487b86a9cfbb..00000000000000 --- a/deps/v8_inspector/platform/v8_inspector/public/ConsoleAPITypes.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2012 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ConsoleAPITypes_h -#define ConsoleAPITypes_h - -namespace blink { - -enum MessageType { - LogMessageType = 1, - DirMessageType, - DirXMLMessageType, - TableMessageType, - TraceMessageType, - StartGroupMessageType, - StartGroupCollapsedMessageType, - EndGroupMessageType, - ClearMessageType, - AssertMessageType, - TimeEndMessageType, - CountMessageType -}; - -} // namespace blink - -#endif // ConsoleAPITypes_h diff --git a/deps/v8_inspector/platform/v8_inspector/public/ConsoleTypes.h b/deps/v8_inspector/platform/v8_inspector/public/ConsoleTypes.h deleted file mode 100644 index fb06fb8ed017ec..00000000000000 --- a/deps/v8_inspector/platform/v8_inspector/public/ConsoleTypes.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2011 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ConsoleTypes_h -#define ConsoleTypes_h - -namespace blink { - -enum MessageSource { - XMLMessageSource, - JSMessageSource, - NetworkMessageSource, - ConsoleAPIMessageSource, - StorageMessageSource, - AppCacheMessageSource, - RenderingMessageSource, - SecurityMessageSource, - OtherMessageSource, - DeprecationMessageSource, -}; - -enum MessageLevel { - DebugMessageLevel = 4, - LogMessageLevel = 1, - InfoMessageLevel = 5, - WarningMessageLevel = 2, - ErrorMessageLevel = 3, - RevokedErrorMessageLevel = 6 -}; - -} // namespace blink - -#endif // ConsoleTypes_h diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8ToProtocolValue.h b/deps/v8_inspector/platform/v8_inspector/public/V8ToProtocolValue.h deleted file mode 100644 index c3c692f9959236..00000000000000 --- a/deps/v8_inspector/platform/v8_inspector/public/V8ToProtocolValue.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8ToProtocolValue_h -#define V8ToProtocolValue_h - -#include "platform/inspector_protocol/Values.h" -#include - -namespace blink { - -PLATFORM_EXPORT std::unique_ptr toProtocolValue(v8::Local, v8::Local, int maxDepth = protocol::Value::maxDepth); - -} // namespace blink - -#endif // V8ToProtocolValue_h diff --git a/deps/v8_inspector/deps/jinja2/.gitignore b/deps/v8_inspector/third_party/jinja2/.gitignore similarity index 100% rename from deps/v8_inspector/deps/jinja2/.gitignore rename to deps/v8_inspector/third_party/jinja2/.gitignore diff --git a/deps/v8_inspector/deps/jinja2/.travis.yml b/deps/v8_inspector/third_party/jinja2/.travis.yml similarity index 100% rename from deps/v8_inspector/deps/jinja2/.travis.yml rename to deps/v8_inspector/third_party/jinja2/.travis.yml diff --git a/deps/v8_inspector/deps/jinja2/AUTHORS b/deps/v8_inspector/third_party/jinja2/AUTHORS similarity index 100% rename from deps/v8_inspector/deps/jinja2/AUTHORS rename to deps/v8_inspector/third_party/jinja2/AUTHORS diff --git a/deps/v8_inspector/deps/jinja2/CHANGES b/deps/v8_inspector/third_party/jinja2/CHANGES similarity index 100% rename from deps/v8_inspector/deps/jinja2/CHANGES rename to deps/v8_inspector/third_party/jinja2/CHANGES diff --git a/deps/v8_inspector/deps/jinja2/LICENSE b/deps/v8_inspector/third_party/jinja2/LICENSE similarity index 98% rename from deps/v8_inspector/deps/jinja2/LICENSE rename to deps/v8_inspector/third_party/jinja2/LICENSE index 31bf900e58e30f..10145a264342b7 100644 --- a/deps/v8_inspector/deps/jinja2/LICENSE +++ b/deps/v8_inspector/third_party/jinja2/LICENSE @@ -1,31 +1,31 @@ -Copyright (c) 2009 by the Jinja Team, see AUTHORS for more details. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright (c) 2009 by the Jinja Team, see AUTHORS for more details. + +Some rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * The names of the contributors may not be used to endorse or + promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/deps/v8_inspector/deps/jinja2/MANIFEST.in b/deps/v8_inspector/third_party/jinja2/MANIFEST.in similarity index 100% rename from deps/v8_inspector/deps/jinja2/MANIFEST.in rename to deps/v8_inspector/third_party/jinja2/MANIFEST.in diff --git a/deps/v8_inspector/deps/jinja2/Makefile b/deps/v8_inspector/third_party/jinja2/Makefile similarity index 100% rename from deps/v8_inspector/deps/jinja2/Makefile rename to deps/v8_inspector/third_party/jinja2/Makefile diff --git a/deps/v8_inspector/deps/jinja2/README.rst b/deps/v8_inspector/third_party/jinja2/README.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/README.rst rename to deps/v8_inspector/third_party/jinja2/README.rst diff --git a/deps/v8_inspector/deps/jinja2/artwork/jinjalogo.svg b/deps/v8_inspector/third_party/jinja2/artwork/jinjalogo.svg similarity index 100% rename from deps/v8_inspector/deps/jinja2/artwork/jinjalogo.svg rename to deps/v8_inspector/third_party/jinja2/artwork/jinjalogo.svg diff --git a/deps/v8_inspector/deps/jinja2/docs/Makefile b/deps/v8_inspector/third_party/jinja2/docs/Makefile similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/Makefile rename to deps/v8_inspector/third_party/jinja2/docs/Makefile diff --git a/deps/v8_inspector/deps/jinja2/docs/_static/.ignore b/deps/v8_inspector/third_party/jinja2/docs/_static/.ignore similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_static/.ignore rename to deps/v8_inspector/third_party/jinja2/docs/_static/.ignore diff --git a/deps/v8_inspector/deps/jinja2/docs/_static/jinja-small.png b/deps/v8_inspector/third_party/jinja2/docs/_static/jinja-small.png similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_static/jinja-small.png rename to deps/v8_inspector/third_party/jinja2/docs/_static/jinja-small.png diff --git a/deps/v8_inspector/deps/jinja2/docs/_templates/sidebarintro.html b/deps/v8_inspector/third_party/jinja2/docs/_templates/sidebarintro.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_templates/sidebarintro.html rename to deps/v8_inspector/third_party/jinja2/docs/_templates/sidebarintro.html diff --git a/deps/v8_inspector/deps/jinja2/docs/_templates/sidebarlogo.html b/deps/v8_inspector/third_party/jinja2/docs/_templates/sidebarlogo.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_templates/sidebarlogo.html rename to deps/v8_inspector/third_party/jinja2/docs/_templates/sidebarlogo.html diff --git a/deps/v8_inspector/deps/jinja2/docs/_themes/LICENSE b/deps/v8_inspector/third_party/jinja2/docs/_themes/LICENSE similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_themes/LICENSE rename to deps/v8_inspector/third_party/jinja2/docs/_themes/LICENSE diff --git a/deps/v8_inspector/deps/jinja2/docs/_themes/README b/deps/v8_inspector/third_party/jinja2/docs/_themes/README similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_themes/README rename to deps/v8_inspector/third_party/jinja2/docs/_themes/README diff --git a/deps/v8_inspector/deps/jinja2/docs/_themes/jinja/layout.html b/deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/layout.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_themes/jinja/layout.html rename to deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/layout.html diff --git a/deps/v8_inspector/deps/jinja2/docs/_themes/jinja/relations.html b/deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/relations.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_themes/jinja/relations.html rename to deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/relations.html diff --git a/deps/v8_inspector/deps/jinja2/docs/_themes/jinja/static/jinja.css_t b/deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/static/jinja.css_t similarity index 99% rename from deps/v8_inspector/deps/jinja2/docs/_themes/jinja/static/jinja.css_t rename to deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/static/jinja.css_t index 7d3b244ae13bb6..3291ba6fd18605 100644 --- a/deps/v8_inspector/deps/jinja2/docs/_themes/jinja/static/jinja.css_t +++ b/deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/static/jinja.css_t @@ -12,11 +12,11 @@ {% set sidebar_width = '220px' %} {% set font_family = 'Georgia, serif' %} {% set header_font_family = 'Crimson Text, ' ~ font_family %} - + @import url("basic.css"); - + /* -- page layout ----------------------------------------------------------- */ - + body { font-family: {{ font_family }}; font-size: 17px; @@ -47,7 +47,7 @@ div.sphinxsidebar { hr { border: 1px solid #B1B4B6; } - + div.body { background-color: #ffffff; color: #3E4349; @@ -58,7 +58,7 @@ img.floatingflask { padding: 0 0 10px 10px; float: right; } - + div.footer { width: {{ page_width }}; margin: 20px auto 30px auto; @@ -74,7 +74,7 @@ div.footer a { div.related { display: none; } - + div.sphinxsidebar a { color: #444; text-decoration: none; @@ -84,7 +84,7 @@ div.sphinxsidebar a { div.sphinxsidebar a:hover { border-bottom: 1px solid #999; } - + div.sphinxsidebar { font-size: 15px; line-height: 1.5; @@ -99,7 +99,7 @@ div.sphinxsidebarwrapper p.logo { margin: 0; text-align: center; } - + div.sphinxsidebar h3, div.sphinxsidebar h4 { font-family: {{ font_family }}; @@ -113,7 +113,7 @@ div.sphinxsidebar h4 { div.sphinxsidebar h4 { font-size: 20px; } - + div.sphinxsidebar h3 a { color: #444; } @@ -124,7 +124,7 @@ div.sphinxsidebar p.logo a:hover, div.sphinxsidebar h3 a:hover { border: none; } - + div.sphinxsidebar p { color: #555; margin: 10px 0; @@ -135,7 +135,7 @@ div.sphinxsidebar ul { padding: 0; color: #000; } - + div.sphinxsidebar input { border: 1px solid #ccc; font-family: {{ font_family }}; @@ -145,19 +145,19 @@ div.sphinxsidebar input { div.sphinxsidebar form.search input[name="q"] { width: 130px; } - + /* -- body styles ----------------------------------------------------------- */ - + a { color: #aa0000; text-decoration: underline; } - + a:hover { color: #dd0000; text-decoration: underline; } - + div.body h1, div.body h2, div.body h3, @@ -170,25 +170,25 @@ div.body h6 { padding: 0; color: black; } - + div.body h1 { margin-top: 0; padding-top: 0; font-size: 240%; } div.body h2 { font-size: 180%; } div.body h3 { font-size: 150%; } div.body h4 { font-size: 130%; } div.body h5 { font-size: 100%; } div.body h6 { font-size: 100%; } - + a.headerlink { color: #ddd; padding: 0 4px; text-decoration: none; } - + a.headerlink:hover { color: #444; background: #eaeaea; } - + div.body p, div.body dd, div.body li { line-height: 1.4em; } @@ -235,20 +235,20 @@ div.note { background-color: #eee; border: 1px solid #ccc; } - + div.seealso { background-color: #ffc; border: 1px solid #ff6; } - + div.topic { background-color: #eee; } - + p.admonition-title { display: inline; } - + p.admonition-title:after { content: ":"; } @@ -342,7 +342,7 @@ ul, ol { margin: 10px 0 10px 30px; padding: 0; } - + pre { background: #eee; padding: 7px 30px; @@ -359,7 +359,7 @@ dl dl pre { margin-left: -90px; padding-left: 90px; } - + tt { background-color: #E8EFF0; color: #222; diff --git a/deps/v8_inspector/deps/jinja2/docs/_themes/jinja/theme.conf b/deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/theme.conf similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/_themes/jinja/theme.conf rename to deps/v8_inspector/third_party/jinja2/docs/_themes/jinja/theme.conf diff --git a/deps/v8_inspector/deps/jinja2/docs/api.rst b/deps/v8_inspector/third_party/jinja2/docs/api.rst similarity index 99% rename from deps/v8_inspector/deps/jinja2/docs/api.rst rename to deps/v8_inspector/third_party/jinja2/docs/api.rst index 04ba157fbba31c..088c8673208087 100644 --- a/deps/v8_inspector/deps/jinja2/docs/api.rst +++ b/deps/v8_inspector/third_party/jinja2/docs/api.rst @@ -197,7 +197,7 @@ useful if you want to dig deeper into Jinja2 or :ref:`develop extensions For a more complex example you can provide a hint. For example the :func:`first` filter creates an undefined object that way:: - return environment.undefined('no first item, sequence was empty') + return environment.undefined('no first item, sequence was empty') If it the `name` or `obj` is known (for example because an attribute was accessed) it should be passed to the undefined object, even if @@ -714,7 +714,7 @@ Here a simple test that checks if a variable is a prime number:: if n % i == 0: return False return True - + You can register it on the template environment by updating the :attr:`~Environment.tests` dict on the environment:: diff --git a/deps/v8_inspector/deps/jinja2/docs/cache_extension.py b/deps/v8_inspector/third_party/jinja2/docs/cache_extension.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/cache_extension.py rename to deps/v8_inspector/third_party/jinja2/docs/cache_extension.py diff --git a/deps/v8_inspector/deps/jinja2/docs/changelog.rst b/deps/v8_inspector/third_party/jinja2/docs/changelog.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/changelog.rst rename to deps/v8_inspector/third_party/jinja2/docs/changelog.rst diff --git a/deps/v8_inspector/deps/jinja2/docs/conf.py b/deps/v8_inspector/third_party/jinja2/docs/conf.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/conf.py rename to deps/v8_inspector/third_party/jinja2/docs/conf.py diff --git a/deps/v8_inspector/deps/jinja2/docs/contents.rst.inc b/deps/v8_inspector/third_party/jinja2/docs/contents.rst.inc similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/contents.rst.inc rename to deps/v8_inspector/third_party/jinja2/docs/contents.rst.inc diff --git a/deps/v8_inspector/deps/jinja2/docs/extensions.rst b/deps/v8_inspector/third_party/jinja2/docs/extensions.rst similarity index 99% rename from deps/v8_inspector/deps/jinja2/docs/extensions.rst rename to deps/v8_inspector/third_party/jinja2/docs/extensions.rst index 955708ba4e67d2..0825fd4f9b7343 100644 --- a/deps/v8_inspector/deps/jinja2/docs/extensions.rst +++ b/deps/v8_inspector/third_party/jinja2/docs/extensions.rst @@ -27,8 +27,8 @@ i18n Extension **Import name:** `jinja2.ext.i18n` -The i18n extension can be used in combination with `gettext`_ or `babel`_. If -the i18n extension is enabled Jinja2 provides a `trans` statement that marks +The i18n extension can be used in combination with `gettext`_ or `babel`_. If +the i18n extension is enabled Jinja2 provides a `trans` statement that marks the wrapped string as translatable and calls `gettext`. After enabling, dummy `_` function that forwards calls to `gettext` is added diff --git a/deps/v8_inspector/deps/jinja2/docs/faq.rst b/deps/v8_inspector/third_party/jinja2/docs/faq.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/faq.rst rename to deps/v8_inspector/third_party/jinja2/docs/faq.rst diff --git a/deps/v8_inspector/deps/jinja2/docs/index.rst b/deps/v8_inspector/third_party/jinja2/docs/index.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/index.rst rename to deps/v8_inspector/third_party/jinja2/docs/index.rst diff --git a/deps/v8_inspector/deps/jinja2/docs/integration.rst b/deps/v8_inspector/third_party/jinja2/docs/integration.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/integration.rst rename to deps/v8_inspector/third_party/jinja2/docs/integration.rst diff --git a/deps/v8_inspector/deps/jinja2/docs/intro.rst b/deps/v8_inspector/third_party/jinja2/docs/intro.rst similarity index 98% rename from deps/v8_inspector/deps/jinja2/docs/intro.rst rename to deps/v8_inspector/third_party/jinja2/docs/intro.rst index b6da5ea5f12ad1..99c3582728f773 100644 --- a/deps/v8_inspector/deps/jinja2/docs/intro.rst +++ b/deps/v8_inspector/third_party/jinja2/docs/intro.rst @@ -64,7 +64,7 @@ which will install the package via `distribute` in development mode. This also has the advantage that the C extensions are compiled. .. _download page: http://pypi.python.org/pypi/Jinja2 -.. _distribute: http://pypi.python.org/pypi/distribute +.. _distribute: http://pypi.python.org/pypi/distribute .. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools .. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall .. _pip: http://pypi.python.org/pypi/pip diff --git a/deps/v8_inspector/deps/jinja2/docs/jinjaext.py b/deps/v8_inspector/third_party/jinja2/docs/jinjaext.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/jinjaext.py rename to deps/v8_inspector/third_party/jinja2/docs/jinjaext.py diff --git a/deps/v8_inspector/deps/jinja2/docs/jinjastyle.sty b/deps/v8_inspector/third_party/jinja2/docs/jinjastyle.sty similarity index 98% rename from deps/v8_inspector/deps/jinja2/docs/jinjastyle.sty rename to deps/v8_inspector/third_party/jinja2/docs/jinjastyle.sty index e93c8d1c6974e9..da811ce376bd12 100644 --- a/deps/v8_inspector/deps/jinja2/docs/jinjastyle.sty +++ b/deps/v8_inspector/third_party/jinja2/docs/jinjastyle.sty @@ -22,7 +22,7 @@ %\sphinxlogo% {\center \vspace*{3cm} - \includegraphics{logo.pdf} + \includegraphics{logo.pdf} \vspace{3cm} \par {\rm\Huge \@title \par}% diff --git a/deps/v8_inspector/deps/jinja2/docs/latexindex.rst b/deps/v8_inspector/third_party/jinja2/docs/latexindex.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/latexindex.rst rename to deps/v8_inspector/third_party/jinja2/docs/latexindex.rst diff --git a/deps/v8_inspector/deps/jinja2/docs/logo.pdf b/deps/v8_inspector/third_party/jinja2/docs/logo.pdf similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/logo.pdf rename to deps/v8_inspector/third_party/jinja2/docs/logo.pdf diff --git a/deps/v8_inspector/deps/jinja2/docs/sandbox.rst b/deps/v8_inspector/third_party/jinja2/docs/sandbox.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/sandbox.rst rename to deps/v8_inspector/third_party/jinja2/docs/sandbox.rst diff --git a/deps/v8_inspector/deps/jinja2/docs/switching.rst b/deps/v8_inspector/third_party/jinja2/docs/switching.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/switching.rst rename to deps/v8_inspector/third_party/jinja2/docs/switching.rst diff --git a/deps/v8_inspector/deps/jinja2/docs/templates.rst b/deps/v8_inspector/third_party/jinja2/docs/templates.rst similarity index 99% rename from deps/v8_inspector/deps/jinja2/docs/templates.rst rename to deps/v8_inspector/third_party/jinja2/docs/templates.rst index 3c169247219908..d9102ecc1b636b 100644 --- a/deps/v8_inspector/deps/jinja2/docs/templates.rst +++ b/deps/v8_inspector/third_party/jinja2/docs/templates.rst @@ -197,14 +197,14 @@ without the `trim_blocks` and `lstrip_blocks` options, this template:: gets rendered with blank lines inside the div::
- + yay - +
But with both `trim_blocks` and `lstrip_blocks` enabled, the template block lines are removed and other whitespace is preserved:: - +
yay
@@ -522,12 +522,12 @@ Working with Automatic Escaping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When automatic escaping is enabled, everything is escaped by default except -for values explicitly marked as safe. Variables and expressions +for values explicitly marked as safe. Variables and expressions can be marked as safe either in: a. the context dictionary by the application with `MarkupSafe.Markup`, or b. the template, with the `|safe` filter - + The main problem with this approach is that Python itself doesn't have the concept of tainted values; so whether a value is safe or unsafe can get lost. diff --git a/deps/v8_inspector/deps/jinja2/docs/tricks.rst b/deps/v8_inspector/third_party/jinja2/docs/tricks.rst similarity index 100% rename from deps/v8_inspector/deps/jinja2/docs/tricks.rst rename to deps/v8_inspector/third_party/jinja2/docs/tricks.rst diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/cycle.py b/deps/v8_inspector/third_party/jinja2/examples/basic/cycle.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/cycle.py rename to deps/v8_inspector/third_party/jinja2/examples/basic/cycle.py diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/debugger.py b/deps/v8_inspector/third_party/jinja2/examples/basic/debugger.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/debugger.py rename to deps/v8_inspector/third_party/jinja2/examples/basic/debugger.py diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/inheritance.py b/deps/v8_inspector/third_party/jinja2/examples/basic/inheritance.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/inheritance.py rename to deps/v8_inspector/third_party/jinja2/examples/basic/inheritance.py diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/templates/broken.html b/deps/v8_inspector/third_party/jinja2/examples/basic/templates/broken.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/templates/broken.html rename to deps/v8_inspector/third_party/jinja2/examples/basic/templates/broken.html diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/templates/subbroken.html b/deps/v8_inspector/third_party/jinja2/examples/basic/templates/subbroken.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/templates/subbroken.html rename to deps/v8_inspector/third_party/jinja2/examples/basic/templates/subbroken.html diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/test.py b/deps/v8_inspector/third_party/jinja2/examples/basic/test.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/test.py rename to deps/v8_inspector/third_party/jinja2/examples/basic/test.py diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/test_filter_and_linestatements.py b/deps/v8_inspector/third_party/jinja2/examples/basic/test_filter_and_linestatements.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/test_filter_and_linestatements.py rename to deps/v8_inspector/third_party/jinja2/examples/basic/test_filter_and_linestatements.py diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/test_loop_filter.py b/deps/v8_inspector/third_party/jinja2/examples/basic/test_loop_filter.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/test_loop_filter.py rename to deps/v8_inspector/third_party/jinja2/examples/basic/test_loop_filter.py diff --git a/deps/v8_inspector/deps/jinja2/examples/basic/translate.py b/deps/v8_inspector/third_party/jinja2/examples/basic/translate.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/basic/translate.py rename to deps/v8_inspector/third_party/jinja2/examples/basic/translate.py diff --git a/deps/v8_inspector/deps/jinja2/examples/bench.py b/deps/v8_inspector/third_party/jinja2/examples/bench.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/bench.py rename to deps/v8_inspector/third_party/jinja2/examples/bench.py diff --git a/deps/v8_inspector/deps/jinja2/examples/profile.py b/deps/v8_inspector/third_party/jinja2/examples/profile.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/profile.py rename to deps/v8_inspector/third_party/jinja2/examples/profile.py diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/django/_form.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/django/_form.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/django/_form.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/django/_form.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/django/_input_field.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/django/_input_field.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/django/_input_field.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/django/_input_field.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/django/_textarea.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/django/_textarea.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/django/_textarea.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/django/_textarea.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/django/index.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/django/index.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/django/index.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/django/index.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/django/layout.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/django/layout.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/django/layout.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/django/layout.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/djangoext.py b/deps/v8_inspector/third_party/jinja2/examples/rwbench/djangoext.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/djangoext.py rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/djangoext.py diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/genshi/helpers.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/genshi/helpers.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/genshi/helpers.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/genshi/helpers.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/genshi/index.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/genshi/index.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/genshi/index.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/genshi/index.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/genshi/layout.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/genshi/layout.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/genshi/layout.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/genshi/layout.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/jinja/helpers.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/jinja/helpers.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/jinja/helpers.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/jinja/helpers.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/jinja/index.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/jinja/index.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/jinja/index.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/jinja/index.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/jinja/layout.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/jinja/layout.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/jinja/layout.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/jinja/layout.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/mako/helpers.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/mako/helpers.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/mako/helpers.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/mako/helpers.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/mako/index.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/mako/index.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/mako/index.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/mako/index.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/mako/layout.html b/deps/v8_inspector/third_party/jinja2/examples/rwbench/mako/layout.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/mako/layout.html rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/mako/layout.html diff --git a/deps/v8_inspector/deps/jinja2/examples/rwbench/rwbench.py b/deps/v8_inspector/third_party/jinja2/examples/rwbench/rwbench.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/examples/rwbench/rwbench.py rename to deps/v8_inspector/third_party/jinja2/examples/rwbench/rwbench.py diff --git a/deps/v8_inspector/deps/jinja2/ext/Vim/jinja.vim b/deps/v8_inspector/third_party/jinja2/ext/Vim/jinja.vim similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/Vim/jinja.vim rename to deps/v8_inspector/third_party/jinja2/ext/Vim/jinja.vim diff --git a/deps/v8_inspector/deps/jinja2/ext/django2jinja/django2jinja.py b/deps/v8_inspector/third_party/jinja2/ext/django2jinja/django2jinja.py similarity index 99% rename from deps/v8_inspector/deps/jinja2/ext/django2jinja/django2jinja.py rename to deps/v8_inspector/third_party/jinja2/ext/django2jinja/django2jinja.py index 824d6a1c3679b5..ad9627ffbc3791 100644 --- a/deps/v8_inspector/deps/jinja2/ext/django2jinja/django2jinja.py +++ b/deps/v8_inspector/third_party/jinja2/ext/django2jinja/django2jinja.py @@ -33,13 +33,13 @@ def write_my_node(writer, node): writer = Writer() writer.node_handlers[MyNode] = write_my_node convert_templates('/path/to/output/folder', writer=writer) - + Here is an example hos to automatically translate your django variables to jinja2:: - + import re # List of tuple (Match pattern, Replace pattern, Exclusion pattern) - + var_re = ((re.compile(r"(u|user)\.is_authenticated"), r"\1.is_authenticated()", None), (re.compile(r"\.non_field_errors"), r".non_field_errors()", None), (re.compile(r"\.label_tag"), r".label_tag()", None), @@ -47,7 +47,7 @@ def write_my_node(writer, node): (re.compile(r"\.as_table"), r".as_table()", None), (re.compile(r"\.as_widget"), r".as_widget()", None), (re.compile(r"\.as_hidden"), r".as_hidden()", None), - + (re.compile(r"\.get_([0-9_\w]+)_url"), r".get_\1_url()", None), (re.compile(r"\.url"), r".url()", re.compile(r"(form|calendar).url")), (re.compile(r"\.get_([0-9_\w]+)_display"), r".get_\1_display()", None), @@ -55,14 +55,14 @@ def write_my_node(writer, node): (re.compile(r"loop\.revcounter"), r"loop.revindex", None), (re.compile(r"request\.GET\.([0-9_\w]+)"), r"request.GET.get('\1', '')", None), (re.compile(r"request\.get_host"), r"request.get_host()", None), - + (re.compile(r"\.all(?!_)"), r".all()", None), (re.compile(r"\.all\.0"), r".all()[0]", None), (re.compile(r"\.([0-9])($|\s+)"), r"[\1]\2", None), (re.compile(r"\.items"), r".items()", None), ) writer = Writer(var_re=var_re) - + For details about the writing process have a look at the module code. :copyright: (c) 2009 by the Jinja Team. @@ -314,7 +314,7 @@ def translate_variable_name(self, var): """Performs variable name translation.""" if self.in_loop and var == 'forloop' or var.startswith('forloop.'): var = var[3:] - + for reg, rep, unless in self.var_re: no_unless = unless and unless.search(var) or True if reg.search(var) and no_unless: @@ -425,7 +425,7 @@ def if_condition(writer, node): join_with = 'and' if node.link_type == core_tags.IfNode.LinkTypes.or_: join_with = 'or' - + for idx, (ifnot, expr) in enumerate(node.bool_exprs): if idx: writer.write(' %s ' % join_with) @@ -734,22 +734,22 @@ def simple_tag(writer, node): writer._filters_warned.add(name) writer.warn('Filter %s probably doesn\'t exist in Jinja' % name) - + if not node.vars_to_resolve: # No argument, pass the request writer.start_variable() writer.write('request|') writer.write(name) writer.end_variable() - return - + return + first_var = node.vars_to_resolve[0] args = node.vars_to_resolve[1:] writer.start_variable() - + # Copied from Writer.filters() writer.node(first_var) - + writer.write('|') writer.write(name) if args: @@ -762,7 +762,7 @@ def simple_tag(writer, node): else: writer.literal(var.literal) writer.write(')') - writer.end_variable() + writer.end_variable() # get rid of node now, it shouldn't be used normally del node diff --git a/deps/v8_inspector/deps/jinja2/ext/django2jinja/example.py b/deps/v8_inspector/third_party/jinja2/ext/django2jinja/example.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/django2jinja/example.py rename to deps/v8_inspector/third_party/jinja2/ext/django2jinja/example.py diff --git a/deps/v8_inspector/deps/jinja2/ext/django2jinja/templates/index.html b/deps/v8_inspector/third_party/jinja2/ext/django2jinja/templates/index.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/django2jinja/templates/index.html rename to deps/v8_inspector/third_party/jinja2/ext/django2jinja/templates/index.html diff --git a/deps/v8_inspector/deps/jinja2/ext/django2jinja/templates/layout.html b/deps/v8_inspector/third_party/jinja2/ext/django2jinja/templates/layout.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/django2jinja/templates/layout.html rename to deps/v8_inspector/third_party/jinja2/ext/django2jinja/templates/layout.html diff --git a/deps/v8_inspector/deps/jinja2/ext/django2jinja/templates/subtemplate.html b/deps/v8_inspector/third_party/jinja2/ext/django2jinja/templates/subtemplate.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/django2jinja/templates/subtemplate.html rename to deps/v8_inspector/third_party/jinja2/ext/django2jinja/templates/subtemplate.html diff --git a/deps/v8_inspector/deps/jinja2/ext/djangojinja2.py b/deps/v8_inspector/third_party/jinja2/ext/djangojinja2.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/djangojinja2.py rename to deps/v8_inspector/third_party/jinja2/ext/djangojinja2.py diff --git a/deps/v8_inspector/deps/jinja2/ext/inlinegettext.py b/deps/v8_inspector/third_party/jinja2/ext/inlinegettext.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/inlinegettext.py rename to deps/v8_inspector/third_party/jinja2/ext/inlinegettext.py diff --git a/deps/v8_inspector/deps/jinja2/ext/jinja.el b/deps/v8_inspector/third_party/jinja2/ext/jinja.el similarity index 100% rename from deps/v8_inspector/deps/jinja2/ext/jinja.el rename to deps/v8_inspector/third_party/jinja2/ext/jinja.el diff --git a/deps/v8_inspector/deps/jinja2/jinja2/__init__.py b/deps/v8_inspector/third_party/jinja2/jinja2/__init__.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/__init__.py rename to deps/v8_inspector/third_party/jinja2/jinja2/__init__.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/_compat.py b/deps/v8_inspector/third_party/jinja2/jinja2/_compat.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/_compat.py rename to deps/v8_inspector/third_party/jinja2/jinja2/_compat.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/_stringdefs.py b/deps/v8_inspector/third_party/jinja2/jinja2/_stringdefs.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/_stringdefs.py rename to deps/v8_inspector/third_party/jinja2/jinja2/_stringdefs.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/bccache.py b/deps/v8_inspector/third_party/jinja2/jinja2/bccache.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/bccache.py rename to deps/v8_inspector/third_party/jinja2/jinja2/bccache.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/compiler.py b/deps/v8_inspector/third_party/jinja2/jinja2/compiler.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/compiler.py rename to deps/v8_inspector/third_party/jinja2/jinja2/compiler.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/constants.py b/deps/v8_inspector/third_party/jinja2/jinja2/constants.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/constants.py rename to deps/v8_inspector/third_party/jinja2/jinja2/constants.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/debug.py b/deps/v8_inspector/third_party/jinja2/jinja2/debug.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/debug.py rename to deps/v8_inspector/third_party/jinja2/jinja2/debug.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/defaults.py b/deps/v8_inspector/third_party/jinja2/jinja2/defaults.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/defaults.py rename to deps/v8_inspector/third_party/jinja2/jinja2/defaults.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/environment.py b/deps/v8_inspector/third_party/jinja2/jinja2/environment.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/environment.py rename to deps/v8_inspector/third_party/jinja2/jinja2/environment.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/exceptions.py b/deps/v8_inspector/third_party/jinja2/jinja2/exceptions.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/exceptions.py rename to deps/v8_inspector/third_party/jinja2/jinja2/exceptions.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/ext.py b/deps/v8_inspector/third_party/jinja2/jinja2/ext.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/ext.py rename to deps/v8_inspector/third_party/jinja2/jinja2/ext.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/filters.py b/deps/v8_inspector/third_party/jinja2/jinja2/filters.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/filters.py rename to deps/v8_inspector/third_party/jinja2/jinja2/filters.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/lexer.py b/deps/v8_inspector/third_party/jinja2/jinja2/lexer.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/lexer.py rename to deps/v8_inspector/third_party/jinja2/jinja2/lexer.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/loaders.py b/deps/v8_inspector/third_party/jinja2/jinja2/loaders.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/loaders.py rename to deps/v8_inspector/third_party/jinja2/jinja2/loaders.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/meta.py b/deps/v8_inspector/third_party/jinja2/jinja2/meta.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/meta.py rename to deps/v8_inspector/third_party/jinja2/jinja2/meta.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/nodes.py b/deps/v8_inspector/third_party/jinja2/jinja2/nodes.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/nodes.py rename to deps/v8_inspector/third_party/jinja2/jinja2/nodes.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/optimizer.py b/deps/v8_inspector/third_party/jinja2/jinja2/optimizer.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/optimizer.py rename to deps/v8_inspector/third_party/jinja2/jinja2/optimizer.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/parser.py b/deps/v8_inspector/third_party/jinja2/jinja2/parser.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/parser.py rename to deps/v8_inspector/third_party/jinja2/jinja2/parser.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/runtime.py b/deps/v8_inspector/third_party/jinja2/jinja2/runtime.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/runtime.py rename to deps/v8_inspector/third_party/jinja2/jinja2/runtime.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/sandbox.py b/deps/v8_inspector/third_party/jinja2/jinja2/sandbox.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/sandbox.py rename to deps/v8_inspector/third_party/jinja2/jinja2/sandbox.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/tests.py b/deps/v8_inspector/third_party/jinja2/jinja2/tests.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/tests.py rename to deps/v8_inspector/third_party/jinja2/jinja2/tests.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/utils.py b/deps/v8_inspector/third_party/jinja2/jinja2/utils.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/utils.py rename to deps/v8_inspector/third_party/jinja2/jinja2/utils.py diff --git a/deps/v8_inspector/deps/jinja2/jinja2/visitor.py b/deps/v8_inspector/third_party/jinja2/jinja2/visitor.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/jinja2/visitor.py rename to deps/v8_inspector/third_party/jinja2/jinja2/visitor.py diff --git a/deps/v8_inspector/deps/jinja2/scripts/jinja2-debug.py b/deps/v8_inspector/third_party/jinja2/scripts/jinja2-debug.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/scripts/jinja2-debug.py rename to deps/v8_inspector/third_party/jinja2/scripts/jinja2-debug.py diff --git a/deps/v8_inspector/deps/jinja2/scripts/make-release.py b/deps/v8_inspector/third_party/jinja2/scripts/make-release.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/scripts/make-release.py rename to deps/v8_inspector/third_party/jinja2/scripts/make-release.py diff --git a/deps/v8_inspector/deps/jinja2/scripts/pylintrc b/deps/v8_inspector/third_party/jinja2/scripts/pylintrc similarity index 99% rename from deps/v8_inspector/deps/jinja2/scripts/pylintrc rename to deps/v8_inspector/third_party/jinja2/scripts/pylintrc index 6ebf385bcee24e..4f85b49066fe0b 100644 --- a/deps/v8_inspector/deps/jinja2/scripts/pylintrc +++ b/deps/v8_inspector/third_party/jinja2/scripts/pylintrc @@ -1,11 +1,11 @@ # lint Python modules using external checkers. -# +# # This is the main checker controling the other ones and the reports # generation. It is itself both a raw checker and an astng checker in order # to: # * handle message activation / deactivation at the module level # * handle some basic but necessary stats'data (number of classes, methods...) -# +# [MASTER] # Specify a configuration file. @@ -92,7 +92,7 @@ comment=no # * undefined variables # * redefinition of variable from builtins or from an outer scope # * use of variable before assigment -# +# [VARIABLES] # Tells wether we should check for unused import in __init__ files. @@ -107,7 +107,7 @@ additional-builtins= # try to find bugs in the code using type inference -# +# [TYPECHECK] # Tells wether missing members accessed in mixin class should be ignored. A @@ -132,7 +132,7 @@ acquired-members=REQUEST,acl_users,aq_parent # * dangerous default values as arguments # * redefinition of function / method / class # * uses of the global statement -# +# [BASIC] # Required attributes for module, separated by a comma @@ -183,7 +183,7 @@ bad-functions=apply,input # checks for sign of poor/misdesign: # * number of methods, attributes, local variables... # * size, complexity of functions, methods -# +# [DESIGN] # Maximum number of arguments for function / method @@ -219,7 +219,7 @@ max-public-methods=20 # * relative / wildcard imports # * cyclic imports # * uses of deprecated modules -# +# [IMPORTS] # Deprecated modules which should not be used, separated by a comma @@ -245,7 +245,7 @@ int-import-graph= # * attributes not defined in the __init__ method # * supported interfaces implementation # * unreachable code -# +# [CLASSES] # List of interface methods to ignore, separated by a comma. This is used for @@ -259,7 +259,7 @@ defining-attr-methods=__init__,__new__,setUp # checks for similarities and duplicated code. This computation may be # memory / CPU intensive, so you should disable it if you experiments some # problems. -# +# [SIMILARITIES] # Minimum lines number of a similarity. @@ -275,7 +275,7 @@ ignore-docstrings=yes # checks for: # * warning notes in the code like FIXME, XXX # * PEP 263: source code with non ascii character but no encoding declaration -# +# [MISCELLANEOUS] # List of note tags to take in consideration, separated by a comma. @@ -287,7 +287,7 @@ notes=FIXME,XXX,TODO # * strict indentation # * line length # * use of <> instead of != -# +# [FORMAT] # Maximum number of characters on a single line. diff --git a/deps/v8_inspector/deps/jinja2/setup.cfg b/deps/v8_inspector/third_party/jinja2/setup.cfg similarity index 100% rename from deps/v8_inspector/deps/jinja2/setup.cfg rename to deps/v8_inspector/third_party/jinja2/setup.cfg diff --git a/deps/v8_inspector/deps/jinja2/setup.py b/deps/v8_inspector/third_party/jinja2/setup.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/setup.py rename to deps/v8_inspector/third_party/jinja2/setup.py diff --git a/deps/v8_inspector/deps/jinja2/tests/conftest.py b/deps/v8_inspector/third_party/jinja2/tests/conftest.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/conftest.py rename to deps/v8_inspector/third_party/jinja2/tests/conftest.py diff --git a/deps/v8_inspector/deps/jinja2/tests/res/__init__.py b/deps/v8_inspector/third_party/jinja2/tests/res/__init__.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/res/__init__.py rename to deps/v8_inspector/third_party/jinja2/tests/res/__init__.py diff --git a/deps/v8_inspector/deps/jinja2/tests/res/templates/broken.html b/deps/v8_inspector/third_party/jinja2/tests/res/templates/broken.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/res/templates/broken.html rename to deps/v8_inspector/third_party/jinja2/tests/res/templates/broken.html diff --git a/deps/v8_inspector/deps/jinja2/tests/res/templates/foo/test.html b/deps/v8_inspector/third_party/jinja2/tests/res/templates/foo/test.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/res/templates/foo/test.html rename to deps/v8_inspector/third_party/jinja2/tests/res/templates/foo/test.html diff --git a/deps/v8_inspector/deps/jinja2/tests/res/templates/syntaxerror.html b/deps/v8_inspector/third_party/jinja2/tests/res/templates/syntaxerror.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/res/templates/syntaxerror.html rename to deps/v8_inspector/third_party/jinja2/tests/res/templates/syntaxerror.html diff --git a/deps/v8_inspector/deps/jinja2/tests/res/templates/test.html b/deps/v8_inspector/third_party/jinja2/tests/res/templates/test.html similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/res/templates/test.html rename to deps/v8_inspector/third_party/jinja2/tests/res/templates/test.html diff --git a/deps/v8_inspector/deps/jinja2/tests/test_api.py b/deps/v8_inspector/third_party/jinja2/tests/test_api.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_api.py rename to deps/v8_inspector/third_party/jinja2/tests/test_api.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_bytecode_cache.py b/deps/v8_inspector/third_party/jinja2/tests/test_bytecode_cache.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_bytecode_cache.py rename to deps/v8_inspector/third_party/jinja2/tests/test_bytecode_cache.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_core_tags.py b/deps/v8_inspector/third_party/jinja2/tests/test_core_tags.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_core_tags.py rename to deps/v8_inspector/third_party/jinja2/tests/test_core_tags.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_debug.py b/deps/v8_inspector/third_party/jinja2/tests/test_debug.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_debug.py rename to deps/v8_inspector/third_party/jinja2/tests/test_debug.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_ext.py b/deps/v8_inspector/third_party/jinja2/tests/test_ext.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_ext.py rename to deps/v8_inspector/third_party/jinja2/tests/test_ext.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_filters.py b/deps/v8_inspector/third_party/jinja2/tests/test_filters.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_filters.py rename to deps/v8_inspector/third_party/jinja2/tests/test_filters.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_imports.py b/deps/v8_inspector/third_party/jinja2/tests/test_imports.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_imports.py rename to deps/v8_inspector/third_party/jinja2/tests/test_imports.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_inheritance.py b/deps/v8_inspector/third_party/jinja2/tests/test_inheritance.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_inheritance.py rename to deps/v8_inspector/third_party/jinja2/tests/test_inheritance.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_lexnparse.py b/deps/v8_inspector/third_party/jinja2/tests/test_lexnparse.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_lexnparse.py rename to deps/v8_inspector/third_party/jinja2/tests/test_lexnparse.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_loader.py b/deps/v8_inspector/third_party/jinja2/tests/test_loader.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_loader.py rename to deps/v8_inspector/third_party/jinja2/tests/test_loader.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_regression.py b/deps/v8_inspector/third_party/jinja2/tests/test_regression.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_regression.py rename to deps/v8_inspector/third_party/jinja2/tests/test_regression.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_security.py b/deps/v8_inspector/third_party/jinja2/tests/test_security.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_security.py rename to deps/v8_inspector/third_party/jinja2/tests/test_security.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_tests.py b/deps/v8_inspector/third_party/jinja2/tests/test_tests.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_tests.py rename to deps/v8_inspector/third_party/jinja2/tests/test_tests.py diff --git a/deps/v8_inspector/deps/jinja2/tests/test_utils.py b/deps/v8_inspector/third_party/jinja2/tests/test_utils.py similarity index 100% rename from deps/v8_inspector/deps/jinja2/tests/test_utils.py rename to deps/v8_inspector/third_party/jinja2/tests/test_utils.py diff --git a/deps/v8_inspector/deps/jinja2/tox.ini b/deps/v8_inspector/third_party/jinja2/tox.ini similarity index 100% rename from deps/v8_inspector/deps/jinja2/tox.ini rename to deps/v8_inspector/third_party/jinja2/tox.ini diff --git a/deps/v8_inspector/deps/markupsafe/.gitignore b/deps/v8_inspector/third_party/markupsafe/.gitignore similarity index 100% rename from deps/v8_inspector/deps/markupsafe/.gitignore rename to deps/v8_inspector/third_party/markupsafe/.gitignore diff --git a/deps/v8_inspector/deps/markupsafe/.travis.yml b/deps/v8_inspector/third_party/markupsafe/.travis.yml similarity index 100% rename from deps/v8_inspector/deps/markupsafe/.travis.yml rename to deps/v8_inspector/third_party/markupsafe/.travis.yml diff --git a/deps/v8_inspector/deps/markupsafe/AUTHORS b/deps/v8_inspector/third_party/markupsafe/AUTHORS similarity index 100% rename from deps/v8_inspector/deps/markupsafe/AUTHORS rename to deps/v8_inspector/third_party/markupsafe/AUTHORS diff --git a/deps/v8_inspector/deps/markupsafe/CHANGES b/deps/v8_inspector/third_party/markupsafe/CHANGES similarity index 100% rename from deps/v8_inspector/deps/markupsafe/CHANGES rename to deps/v8_inspector/third_party/markupsafe/CHANGES diff --git a/deps/v8_inspector/deps/markupsafe/LICENSE b/deps/v8_inspector/third_party/markupsafe/LICENSE similarity index 100% rename from deps/v8_inspector/deps/markupsafe/LICENSE rename to deps/v8_inspector/third_party/markupsafe/LICENSE diff --git a/deps/v8_inspector/deps/markupsafe/MANIFEST.in b/deps/v8_inspector/third_party/markupsafe/MANIFEST.in similarity index 100% rename from deps/v8_inspector/deps/markupsafe/MANIFEST.in rename to deps/v8_inspector/third_party/markupsafe/MANIFEST.in diff --git a/deps/v8_inspector/deps/markupsafe/Makefile b/deps/v8_inspector/third_party/markupsafe/Makefile similarity index 100% rename from deps/v8_inspector/deps/markupsafe/Makefile rename to deps/v8_inspector/third_party/markupsafe/Makefile diff --git a/deps/v8_inspector/deps/markupsafe/README.rst b/deps/v8_inspector/third_party/markupsafe/README.rst similarity index 100% rename from deps/v8_inspector/deps/markupsafe/README.rst rename to deps/v8_inspector/third_party/markupsafe/README.rst diff --git a/deps/v8_inspector/deps/markupsafe/bench/bench_basic.py b/deps/v8_inspector/third_party/markupsafe/bench/bench_basic.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/bench/bench_basic.py rename to deps/v8_inspector/third_party/markupsafe/bench/bench_basic.py diff --git a/deps/v8_inspector/deps/markupsafe/bench/bench_largestring.py b/deps/v8_inspector/third_party/markupsafe/bench/bench_largestring.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/bench/bench_largestring.py rename to deps/v8_inspector/third_party/markupsafe/bench/bench_largestring.py diff --git a/deps/v8_inspector/deps/markupsafe/bench/bench_long_empty_string.py b/deps/v8_inspector/third_party/markupsafe/bench/bench_long_empty_string.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/bench/bench_long_empty_string.py rename to deps/v8_inspector/third_party/markupsafe/bench/bench_long_empty_string.py diff --git a/deps/v8_inspector/deps/markupsafe/bench/bench_long_suffix.py b/deps/v8_inspector/third_party/markupsafe/bench/bench_long_suffix.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/bench/bench_long_suffix.py rename to deps/v8_inspector/third_party/markupsafe/bench/bench_long_suffix.py diff --git a/deps/v8_inspector/deps/markupsafe/bench/bench_short_empty_string.py b/deps/v8_inspector/third_party/markupsafe/bench/bench_short_empty_string.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/bench/bench_short_empty_string.py rename to deps/v8_inspector/third_party/markupsafe/bench/bench_short_empty_string.py diff --git a/deps/v8_inspector/deps/markupsafe/bench/runbench.py b/deps/v8_inspector/third_party/markupsafe/bench/runbench.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/bench/runbench.py rename to deps/v8_inspector/third_party/markupsafe/bench/runbench.py diff --git a/deps/v8_inspector/deps/markupsafe/markupsafe/__init__.py b/deps/v8_inspector/third_party/markupsafe/markupsafe/__init__.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/markupsafe/__init__.py rename to deps/v8_inspector/third_party/markupsafe/markupsafe/__init__.py diff --git a/deps/v8_inspector/deps/markupsafe/markupsafe/_compat.py b/deps/v8_inspector/third_party/markupsafe/markupsafe/_compat.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/markupsafe/_compat.py rename to deps/v8_inspector/third_party/markupsafe/markupsafe/_compat.py diff --git a/deps/v8_inspector/deps/markupsafe/markupsafe/_constants.py b/deps/v8_inspector/third_party/markupsafe/markupsafe/_constants.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/markupsafe/_constants.py rename to deps/v8_inspector/third_party/markupsafe/markupsafe/_constants.py diff --git a/deps/v8_inspector/deps/markupsafe/markupsafe/_native.py b/deps/v8_inspector/third_party/markupsafe/markupsafe/_native.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/markupsafe/_native.py rename to deps/v8_inspector/third_party/markupsafe/markupsafe/_native.py diff --git a/deps/v8_inspector/deps/markupsafe/markupsafe/_speedups.c b/deps/v8_inspector/third_party/markupsafe/markupsafe/_speedups.c similarity index 100% rename from deps/v8_inspector/deps/markupsafe/markupsafe/_speedups.c rename to deps/v8_inspector/third_party/markupsafe/markupsafe/_speedups.c diff --git a/deps/v8_inspector/deps/markupsafe/markupsafe/tests.py b/deps/v8_inspector/third_party/markupsafe/markupsafe/tests.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/markupsafe/tests.py rename to deps/v8_inspector/third_party/markupsafe/markupsafe/tests.py diff --git a/deps/v8_inspector/deps/markupsafe/setup.py b/deps/v8_inspector/third_party/markupsafe/setup.py similarity index 100% rename from deps/v8_inspector/deps/markupsafe/setup.py rename to deps/v8_inspector/third_party/markupsafe/setup.py diff --git a/deps/v8_inspector/deps/markupsafe/tox.ini b/deps/v8_inspector/third_party/markupsafe/tox.ini similarity index 100% rename from deps/v8_inspector/deps/markupsafe/tox.ini rename to deps/v8_inspector/third_party/markupsafe/tox.ini diff --git a/deps/v8_inspector/third_party/v8_inspector/LICENSE b/deps/v8_inspector/third_party/v8_inspector/LICENSE new file mode 100644 index 00000000000000..a32e00ce6be362 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/LICENSE @@ -0,0 +1,27 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/deps/v8_inspector/platform/inspector_protocol/Allocator.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Allocator.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/Allocator.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Allocator.h diff --git a/deps/v8_inspector/platform/inspector_protocol/Array.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Array.h similarity index 87% rename from deps/v8_inspector/platform/inspector_protocol/Array.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Array.h index b75f51742977c7..d92af3a5ed7d05 100644 --- a/deps/v8_inspector/platform/inspector_protocol/Array.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Array.h @@ -5,13 +5,14 @@ #ifndef Array_h #define Array_h -#include "platform/inspector_protocol/Collections.h" #include "platform/inspector_protocol/ErrorSupport.h" #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" #include "platform/inspector_protocol/ValueConversions.h" #include "platform/inspector_protocol/Values.h" +#include + namespace blink { namespace protocol { @@ -33,9 +34,9 @@ class ArrayBase { errors->push(); std::unique_ptr> result(new Array()); for (size_t i = 0; i < array->size(); ++i) { - errors->setName(String16::number(i)); + errors->setName(String16::fromInteger(i)); T item = FromValue::parse(array->at(i), errors); - result->m_vector.append(item); + result->m_vector.push_back(item); } errors->pop(); if (errors->hasErrors()) @@ -45,7 +46,7 @@ class ArrayBase { void addItem(const T& value) { - m_vector.append(value); + m_vector.push_back(value); } size_t length() @@ -67,7 +68,7 @@ class ArrayBase { } private: - protocol::Vector m_vector; + std::vector m_vector; }; template<> class Array : public ArrayBase {}; @@ -94,9 +95,9 @@ class Array { std::unique_ptr> result(new Array()); errors->push(); for (size_t i = 0; i < array->size(); ++i) { - errors->setName(String16::number(i)); + errors->setName(String16::fromInteger(i)); std::unique_ptr item = FromValue::parse(array->at(i), errors); - result->m_vector.append(std::move(item)); + result->m_vector.push_back(std::move(item)); } errors->pop(); if (errors->hasErrors()) @@ -106,7 +107,7 @@ class Array { void addItem(std::unique_ptr value) { - m_vector.append(std::move(value)); + m_vector.push_back(std::move(value)); } size_t length() @@ -116,7 +117,7 @@ class Array { T* get(size_t index) { - return m_vector[index]; + return m_vector[index].get(); } std::unique_ptr serialize() @@ -128,7 +129,7 @@ class Array { } private: - protocol::Vector> m_vector; + std::vector> m_vector; }; } // namespace platform diff --git a/deps/v8_inspector/platform/inspector_protocol/BackendCallback.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/BackendCallback.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/BackendCallback.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/BackendCallback.h diff --git a/deps/v8_inspector/platform/inspector_protocol/CodeGenerator.py b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/CodeGenerator.py similarity index 98% rename from deps/v8_inspector/platform/inspector_protocol/CodeGenerator.py rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/CodeGenerator.py index 4c11161a3cad63..c785c79b528fd1 100644 --- a/deps/v8_inspector/platform/inspector_protocol/CodeGenerator.py +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/CodeGenerator.py @@ -25,13 +25,15 @@ # Insert at 1 so at front to override system libraries, and # after path[0] == invoking script dir third_party_dir = os.path.normpath(os.path.join( - module_path, os.pardir, os.pardir, os.pardir, os.pardir)) + module_path, os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, + "third_party")) if os.path.isdir(third_party_dir): sys.path.insert(1, third_party_dir) # In Node, it is in deps folder deps_dir = os.path.normpath(os.path.join( - module_path, os.pardir, os.pardir, "deps")) + module_path, os.pardir, os.pardir, os.pardir, os.pardir, "third_party")) + if os.path.isdir(deps_dir): sys.path.insert(1, os.path.join(deps_dir, "jinja2")) sys.path.insert(1, os.path.join(deps_dir, "markupsafe")) @@ -215,8 +217,8 @@ def create_primitive_type_definition(type): "boolean": "false" } jsontypes = { - "number": "TypeNumber", - "integer": "TypeNumber", + "number": "TypeDouble", + "integer": "TypeInteger", "boolean": "TypeBoolean", } return { diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Collections.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Collections.h new file mode 100644 index 00000000000000..a89bef413811e3 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Collections.h @@ -0,0 +1,46 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef Collections_h +#define Collections_h + +#include + +#if defined(__APPLE__) && !defined(_LIBCPP_VERSION) +#include +#include + +namespace blink { +namespace protocol { + +template using HashMap = std::map; +template using HashSet = std::set; + +} // namespace protocol +} // namespace blink + +#else +#include +#include + +namespace blink { +namespace protocol { + +template using HashMap = std::unordered_map; +template using HashSet = std::unordered_set; + +} // namespace protocol +} // namespace blink + +#endif // defined(__APPLE__) && !defined(_LIBCPP_VERSION) + +// Macro that returns a compile time constant with the length of an array, but gives an error if passed a non-array. +template char (&ArrayLengthHelperFunction(T (&)[Size]))[Size]; +// GCC needs some help to deduce a 0 length array. +#if defined(__GNUC__) +template char (&ArrayLengthHelperFunction(T (&)[0]))[0]; +#endif +#define PROTOCOL_ARRAY_LENGTH(array) sizeof(::ArrayLengthHelperFunction(array)) + +#endif // !defined(Collections_h) diff --git a/deps/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp similarity index 94% rename from deps/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp index 69798726515c11..49422eba09a9ca 100644 --- a/deps/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp @@ -18,7 +18,7 @@ DispatcherBase::WeakPtr::WeakPtr(DispatcherBase* dispatcher) : m_dispatcher(disp DispatcherBase::WeakPtr::~WeakPtr() { if (m_dispatcher) - m_dispatcher->m_weakPtrs.remove(this); + m_dispatcher->m_weakPtrs.erase(this); } DispatcherBase::Callback::Callback(std::unique_ptr backendImpl, int callId) @@ -73,7 +73,7 @@ void DispatcherBase::sendResponse(int callId, const ErrorString& invocationError } std::unique_ptr responseMessage = DictionaryValue::create(); - responseMessage->setNumber("id", callId); + responseMessage->setInteger("id", callId); responseMessage->setObject("result", std::move(result)); if (m_frontendChannel) m_frontendChannel->sendProtocolResponse(callId, responseMessage->toJSONString()); @@ -92,14 +92,14 @@ void DispatcherBase::sendResponse(int callId, const ErrorString& invocationError static void reportProtocolError(FrontendChannel* frontendChannel, int callId, DispatcherBase::CommonErrorCode code, const String16& errorMessage, ErrorSupport* errors) { std::unique_ptr error = DictionaryValue::create(); - error->setNumber("code", code); + error->setInteger("code", code); error->setString("message", errorMessage); DCHECK(error); if (errors && errors->hasErrors()) error->setString("data", errors->errors()); std::unique_ptr message = DictionaryValue::create(); message->setObject("error", std::move(error)); - message->setNumber("id", callId); + message->setInteger("id", callId); frontendChannel->sendProtocolResponse(callId, message->toJSONString()); } @@ -113,14 +113,14 @@ void DispatcherBase::clearFrontend() { m_frontendChannel = nullptr; for (auto& weak : m_weakPtrs) - weak.first->dispose(); + weak->dispose(); m_weakPtrs.clear(); } std::unique_ptr DispatcherBase::weakPtr() { std::unique_ptr weak(new DispatcherBase::WeakPtr(this)); - m_weakPtrs.add(weak.get()); + m_weakPtrs.insert(weak.get()); return weak; } @@ -129,7 +129,7 @@ UberDispatcher::UberDispatcher(FrontendChannel* frontendChannel) void UberDispatcher::registerBackend(const String16& name, std::unique_ptr dispatcher) { - m_dispatchers.set(name, std::move(dispatcher)); + m_dispatchers[name] = std::move(dispatcher); } void UberDispatcher::dispatch(const String16& message) @@ -143,7 +143,7 @@ void UberDispatcher::dispatch(const String16& message) int callId = 0; protocol::Value* callIdValue = messageObject->get("id"); - bool success = callIdValue->asNumber(&callId); + bool success = callIdValue->asInteger(&callId); if (!success) return; diff --git a/deps/v8_inspector/platform/inspector_protocol/DispatcherBase.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/DispatcherBase.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/DispatcherBase.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/DispatcherBase.h diff --git a/deps/v8_inspector/platform/inspector_protocol/ErrorSupport.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ErrorSupport.cpp similarity index 91% rename from deps/v8_inspector/platform/inspector_protocol/ErrorSupport.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ErrorSupport.cpp index dc9e66373ee271..0ad89ade1c47d0 100644 --- a/deps/v8_inspector/platform/inspector_protocol/ErrorSupport.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ErrorSupport.cpp @@ -29,12 +29,12 @@ void ErrorSupport::setName(const String16& name) void ErrorSupport::push() { - m_path.append(String16()); + m_path.push_back(String16()); } void ErrorSupport::pop() { - m_path.removeLast(); + m_path.pop_back(); } void ErrorSupport::addError(const String16& error) @@ -42,12 +42,12 @@ void ErrorSupport::addError(const String16& error) String16Builder builder; for (size_t i = 0; i < m_path.size(); ++i) { if (i) - builder.append("."); + builder.append('.'); builder.append(m_path[i]); } builder.append(": "); builder.append(error); - m_errors.append(builder.toString()); + m_errors.push_back(builder.toString()); } bool ErrorSupport::hasErrors() diff --git a/deps/v8_inspector/platform/inspector_protocol/ErrorSupport.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ErrorSupport.h similarity index 86% rename from deps/v8_inspector/platform/inspector_protocol/ErrorSupport.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ErrorSupport.h index bb7e064934b01f..56ac442435262b 100644 --- a/deps/v8_inspector/platform/inspector_protocol/ErrorSupport.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ErrorSupport.h @@ -5,10 +5,11 @@ #ifndef ErrorSupport_h #define ErrorSupport_h -#include "platform/inspector_protocol/Collections.h" #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" +#include + namespace blink { namespace protocol { @@ -28,8 +29,8 @@ class PLATFORM_EXPORT ErrorSupport { String16 errors(); private: - protocol::Vector m_path; - protocol::Vector m_errors; + std::vector m_path; + std::vector m_errors; String16* m_errorString; }; diff --git a/deps/v8_inspector/platform/inspector_protocol/FrontendChannel.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/FrontendChannel.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/FrontendChannel.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/FrontendChannel.h diff --git a/deps/v8_inspector/platform/inspector_protocol/Maybe.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Maybe.h similarity index 98% rename from deps/v8_inspector/platform/inspector_protocol/Maybe.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Maybe.h index 3fcd081d89f12a..cf372e0bbe2015 100644 --- a/deps/v8_inspector/platform/inspector_protocol/Maybe.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Maybe.h @@ -18,7 +18,7 @@ class String16; template class Maybe { public: - Maybe() { } + Maybe() : m_value() { } Maybe(std::unique_ptr value) : m_value(std::move(value)) { } void operator=(std::unique_ptr value) { m_value = std::move(value); } T* fromJust() const { DCHECK(m_value); return m_value.get(); } diff --git a/deps/v8_inspector/platform/inspector_protocol/OWNERS b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/OWNERS similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/OWNERS rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/OWNERS diff --git a/deps/v8_inspector/platform/inspector_protocol/Object.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Object.cpp similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/Object.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Object.cpp diff --git a/deps/v8_inspector/platform/inspector_protocol/Object.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Object.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/Object.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Object.h diff --git a/deps/v8_inspector/platform/inspector_protocol/Parser.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Parser.cpp similarity index 98% rename from deps/v8_inspector/platform/inspector_protocol/Parser.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Parser.cpp index 1c267f871a96b2..4193108b279162 100644 --- a/deps/v8_inspector/platform/inspector_protocol/Parser.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Parser.cpp @@ -382,7 +382,11 @@ std::unique_ptr buildValue(const UChar* start, const UChar* end, const UC double value = String16::charactersToDouble(tokenStart, tokenEnd - tokenStart, &ok); if (!ok) return nullptr; - result = FundamentalValue::create(value); + int number = static_cast(value); + if (number == value) + result = FundamentalValue::create(number); + else + result = FundamentalValue::create(value); break; } case StringLiteral: { diff --git a/deps/v8_inspector/platform/inspector_protocol/Parser.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Parser.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/Parser.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Parser.h diff --git a/deps/v8_inspector/platform/inspector_protocol/ParserTest.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ParserTest.cpp similarity index 88% rename from deps/v8_inspector/platform/inspector_protocol/ParserTest.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ParserTest.cpp index 1dfeb4a4fbb983..1a8f44289f2a7b 100644 --- a/deps/v8_inspector/platform/inspector_protocol/ParserTest.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ParserTest.cpp @@ -41,13 +41,13 @@ TEST(ParserTest, Reading) EXPECT_EQ(Value::TypeNull, root->type()); root = parseJSON("40 /* comment */"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); - EXPECT_TRUE(root->asNumber(&intVal)); + EXPECT_EQ(Value::TypeInteger, root->type()); + EXPECT_TRUE(root->asInteger(&intVal)); EXPECT_EQ(40, intVal); root = parseJSON("/**/ 40 /* multi-line\n comment */ // more comment"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); - EXPECT_TRUE(root->asNumber(&intVal)); + EXPECT_EQ(Value::TypeInteger, root->type()); + EXPECT_TRUE(root->asInteger(&intVal)); EXPECT_EQ(40, intVal); root = parseJSON("true // comment"); ASSERT_TRUE(root.get()); @@ -63,11 +63,11 @@ TEST(ParserTest, Reading) EXPECT_EQ(2u, list->size()); tmpValue = list->at(0); ASSERT_TRUE(tmpValue); - EXPECT_TRUE(tmpValue->asNumber(&intVal)); + EXPECT_TRUE(tmpValue->asInteger(&intVal)); EXPECT_EQ(1, intVal); tmpValue = list->at(1); ASSERT_TRUE(tmpValue); - EXPECT_TRUE(tmpValue->asNumber(&intVal)); + EXPECT_TRUE(tmpValue->asInteger(&intVal)); EXPECT_EQ(3, intVal); root = parseJSON("[1, /*a*/2, 3]"); ASSERT_TRUE(root.get()); @@ -76,23 +76,23 @@ TEST(ParserTest, Reading) EXPECT_EQ(3u, list->size()); root = parseJSON("/* comment **/42"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); - EXPECT_TRUE(root->asNumber(&intVal)); + EXPECT_EQ(Value::TypeInteger, root->type()); + EXPECT_TRUE(root->asInteger(&intVal)); EXPECT_EQ(42, intVal); root = parseJSON( "/* comment **/\n" "// */ 43\n" "44"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); - EXPECT_TRUE(root->asNumber(&intVal)); + EXPECT_EQ(Value::TypeInteger, root->type()); + EXPECT_TRUE(root->asInteger(&intVal)); EXPECT_EQ(44, intVal); // Test number formats root = parseJSON("43"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); - EXPECT_TRUE(root->asNumber(&intVal)); + EXPECT_EQ(Value::TypeInteger, root->type()); + EXPECT_TRUE(root->asInteger(&intVal)); EXPECT_EQ(43, intVal); // According to RFC4627, oct, hex, and leading zeros are invalid JSON. @@ -107,9 +107,9 @@ TEST(ParserTest, Reading) // clause). root = parseJSON("0"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeInteger, root->type()); intVal = 1; - EXPECT_TRUE(root->asNumber(&intVal)); + EXPECT_TRUE(root->asInteger(&intVal)); EXPECT_EQ(0, intVal); // Numbers that overflow ints should succeed, being internally promoted to @@ -117,58 +117,58 @@ TEST(ParserTest, Reading) root = parseJSON("2147483648"); ASSERT_TRUE(root.get()); double doubleVal; - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeDouble, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(2147483648.0, doubleVal); root = parseJSON("-2147483649"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeDouble, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(-2147483649.0, doubleVal); // Parse a double root = parseJSON("43.1"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeDouble, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(43.1, doubleVal); root = parseJSON("4.3e-1"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeDouble, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(.43, doubleVal); root = parseJSON("2.1e0"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeDouble, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(2.1, doubleVal); root = parseJSON("2.1e+0001"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeInteger, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(21.0, doubleVal); root = parseJSON("0.01"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeDouble, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(0.01, doubleVal); root = parseJSON("1.00"); ASSERT_TRUE(root.get()); - EXPECT_EQ(Value::TypeNumber, root->type()); + EXPECT_EQ(Value::TypeInteger, root->type()); doubleVal = 0.0; - EXPECT_TRUE(root->asNumber(&doubleVal)); + EXPECT_TRUE(root->asDouble(&doubleVal)); EXPECT_DOUBLE_EQ(1.0, doubleVal); // Fractional parts must have a digit before and after the decimal point. @@ -312,7 +312,7 @@ TEST(ParserTest, Reading) protocol::DictionaryValue* objectVal = DictionaryValue::cast(root.get()); ASSERT_TRUE(objectVal); doubleVal = 0.0; - EXPECT_TRUE(objectVal->getNumber("number", &doubleVal)); + EXPECT_TRUE(objectVal->getDouble("number", &doubleVal)); EXPECT_DOUBLE_EQ(9.87654321, doubleVal); protocol::Value* nullVal = objectVal->get("null"); ASSERT_TRUE(nullVal); @@ -363,14 +363,14 @@ TEST(ParserTest, Reading) objectVal = DictionaryValue::cast(root.get()); ASSERT_TRUE(objectVal); int integerValue = 0; - EXPECT_TRUE(objectVal->getNumber("a.b", &integerValue)); + EXPECT_TRUE(objectVal->getInteger("a.b", &integerValue)); EXPECT_EQ(3, integerValue); - EXPECT_TRUE(objectVal->getNumber("c", &integerValue)); + EXPECT_TRUE(objectVal->getInteger("c", &integerValue)); EXPECT_EQ(2, integerValue); innerObject = objectVal->getObject("d.e.f"); ASSERT_TRUE(innerObject); EXPECT_EQ(1U, innerObject->size()); - EXPECT_TRUE(innerObject->getNumber("g.h.i.j", &integerValue)); + EXPECT_TRUE(innerObject->getInteger("g.h.i.j", &integerValue)); EXPECT_EQ(1, integerValue); root = parseJSON("{\"a\":{\"b\":2},\"a.b\":1}"); @@ -380,9 +380,9 @@ TEST(ParserTest, Reading) ASSERT_TRUE(objectVal); innerObject = objectVal->getObject("a"); ASSERT_TRUE(innerObject); - EXPECT_TRUE(innerObject->getNumber("b", &integerValue)); + EXPECT_TRUE(innerObject->getInteger("b", &integerValue)); EXPECT_EQ(2, integerValue); - EXPECT_TRUE(objectVal->getNumber("a.b", &integerValue)); + EXPECT_TRUE(objectVal->getInteger("a.b", &integerValue)); EXPECT_EQ(1, integerValue); // Invalid, no closing brace @@ -469,7 +469,7 @@ TEST(ParserTest, Reading) root = parseJSON("10"); ASSERT_TRUE(root.get()); - EXPECT_TRUE(root->asNumber(&integerValue)); + EXPECT_TRUE(root->asInteger(&integerValue)); EXPECT_EQ(10, integerValue); root = parseJSON("\"root\""); diff --git a/deps/v8_inspector/platform/inspector_protocol/Platform.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Platform.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/Platform.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Platform.h diff --git a/deps/v8_inspector/platform/inspector_protocol/PlatformSTL.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/PlatformSTL.h similarity index 90% rename from deps/v8_inspector/platform/inspector_protocol/PlatformSTL.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/PlatformSTL.h index 3e687b994c951e..33ca199b1f4e3b 100644 --- a/deps/v8_inspector/platform/inspector_protocol/PlatformSTL.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/PlatformSTL.h @@ -122,6 +122,7 @@ template class unique_ptr { unique_ptr() : m_ptr(nullptr) {} unique_ptr(std::nullptr_t) : m_ptr(nullptr) {} + unique_ptr(const unique_ptr&); unique_ptr(unique_ptr&&); template ::value>::type> unique_ptr(unique_ptr&&); @@ -134,7 +135,10 @@ template class unique_ptr { PtrType get() const { return m_ptr; } void reset(PtrType = nullptr); - PtrType release(); + PtrType release() + { + return this->internalRelease(); + } ValueType& operator*() const { DCHECK(m_ptr); return *m_ptr; } PtrType operator->() const { DCHECK(m_ptr); return m_ptr; } @@ -146,7 +150,7 @@ template class unique_ptr { unique_ptr& operator=(std::nullptr_t) { reset(); return *this; } - + unique_ptr& operator=(const unique_ptr&); unique_ptr& operator=(unique_ptr&&); template unique_ptr& operator=(unique_ptr&&); @@ -157,6 +161,12 @@ template class unique_ptr { explicit unique_ptr(PtrType ptr) : m_ptr(ptr) {} private: + PtrType internalRelease() const + { + PtrType ptr = m_ptr; + m_ptr = nullptr; + return ptr; + } // We should never have two unique_ptrs for the same underlying object // (otherwise we'll get double-destruction), so these equality operators @@ -172,7 +182,7 @@ template class unique_ptr { return false; } - PtrType m_ptr; + mutable PtrType m_ptr; }; @@ -180,16 +190,10 @@ template inline void unique_ptr::reset(PtrType ptr) { PtrType p = m_ptr; m_ptr = ptr; + DCHECK(!p || m_ptr != p); OwnedPtrDeleter::deletePtr(p); } -template inline typename unique_ptr::PtrType unique_ptr::release() -{ - PtrType ptr = m_ptr; - m_ptr = nullptr; - return ptr; -} - template inline typename unique_ptr::ValueType& unique_ptr::operator[](std::ptrdiff_t i) const { static_assert(is_array::value, "elements access is possible for arrays only"); @@ -198,8 +202,13 @@ template inline typename unique_ptr::ValueType& unique_ptr::o return m_ptr[i]; } +template inline unique_ptr::unique_ptr(const unique_ptr& o) + : m_ptr(o.internalRelease()) +{ +} + template inline unique_ptr::unique_ptr(unique_ptr&& o) - : m_ptr(o.release()) + : m_ptr(o.internalRelease()) { } @@ -210,13 +219,15 @@ template inline unique_ptr::unique_ptr(unique_ptr&& static_assert(!is_array::value, "pointers to array must never be converted"); } -template inline unique_ptr& unique_ptr::operator=(unique_ptr&& o) +template inline unique_ptr& unique_ptr::operator=(const unique_ptr& o) { - PtrType ptr = m_ptr; - m_ptr = o.release(); - DCHECK(!ptr || m_ptr != ptr); - OwnedPtrDeleter::deletePtr(ptr); + reset(o.internalRelease()); + return *this; +} +template inline unique_ptr& unique_ptr::operator=(unique_ptr&& o) +{ + reset(o.internalRelease()); return *this; } diff --git a/deps/v8_inspector/platform/inspector_protocol/PlatformWTF.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/PlatformWTF.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/PlatformWTF.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/PlatformWTF.h diff --git a/deps/v8_inspector/platform/inspector_protocol/String16.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16.h similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/String16.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16.h diff --git a/deps/v8_inspector/platform/inspector_protocol/String16STL.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.cpp similarity index 98% rename from deps/v8_inspector/platform/inspector_protocol/String16STL.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.cpp index 08c3e448c3b294..4883f4ceda46e1 100644 --- a/deps/v8_inspector/platform/inspector_protocol/String16STL.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.cpp @@ -562,20 +562,14 @@ std::string String16::utf8() const char* buffer = bufferVector.data(); const UChar* characters = m_impl.data(); - bool strict = false; - ConversionResult result = convertUTF16ToUTF8(&characters, characters + length, &buffer, buffer + bufferVector.size(), strict); + ConversionResult result = convertUTF16ToUTF8(&characters, characters + length, &buffer, buffer + bufferVector.size(), false); DCHECK(result != targetExhausted); // (length * 3) should be sufficient for any conversion // Only produced from strict conversion. - if (result == sourceIllegal) { - DCHECK(strict); - return std::string(); - } + DCHECK(result != sourceIllegal); // Check for an unconverted high surrogate. if (result == sourceExhausted) { - if (strict) - return std::string(); // This should be one unpaired high surrogate. Treat it the same // was as an unpaired high surrogate would have been handled in // the middle of a string with non-strict conversion - which is diff --git a/deps/v8_inspector/platform/inspector_protocol/String16STL.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.h similarity index 91% rename from deps/v8_inspector/platform/inspector_protocol/String16STL.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.h index e76e9775fb9ebc..703e5b0f025d94 100644 --- a/deps/v8_inspector/platform/inspector_protocol/String16STL.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16STL.h @@ -42,7 +42,7 @@ class String16 { const UChar* characters16() const { return m_impl.c_str(); } std::string utf8() const; static String16 fromUTF8(const char* stringStart, size_t length); - static String16 number(int i) { return String16(String16::intToString(i).c_str()); } + static String16 fromInteger(int i) { return String16(String16::intToString(i).c_str()); } static String16 fromDouble(double d) { return String16(String16::doubleToString(d).c_str()); } static String16 fromDoubleFixedPrecision(double d, int len) { return String16(String16::doubleToString(d).c_str()); } @@ -136,7 +136,7 @@ class String16 { // presubmit: allow wstring wstring m_impl; mutable bool has_hash = false; - mutable std::size_t hash_code; + mutable std::size_t hash_code = 0; }; static inline bool isSpaceOrNewline(UChar c) @@ -170,7 +170,12 @@ class String16Builder { void appendNumber(int i) { - m_impl = m_impl + String16::number(i).impl(); + m_impl = m_impl + String16::fromInteger(i).impl(); + } + + void appendNumber(double d) + { + m_impl = m_impl + String16::fromDoubleFixedPrecision(d, 6).impl(); } void append(const UChar* c, size_t length) @@ -238,6 +243,20 @@ class String { }; } // namespace WTF +#if !defined(__APPLE__) || defined(_LIBCPP_VERSION) + +namespace std { +template<> struct hash { + std::size_t operator()(const String16& string) const + { + return string.hash(); + } +}; + +} // namespace std + +#endif // !defined(__APPLE__) || defined(_LIBCPP_VERSION) + using String = WTF::String; #endif // !defined(String16STL_h) diff --git a/deps/v8_inspector/platform/inspector_protocol/String16WTF.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16WTF.cpp similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/String16WTF.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16WTF.cpp diff --git a/deps/v8_inspector/platform/inspector_protocol/String16WTF.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16WTF.h similarity index 91% rename from deps/v8_inspector/platform/inspector_protocol/String16WTF.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16WTF.h index 57a91d82c6f68d..19c56256f0dec4 100644 --- a/deps/v8_inspector/platform/inspector_protocol/String16WTF.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/String16WTF.h @@ -11,6 +11,7 @@ #include "wtf/text/StringConcatenate.h" #include "wtf/text/StringHash.h" #include "wtf/text/StringToNumber.h" +#include "wtf/text/StringView.h" #include "wtf/text/WTFString.h" namespace blink { @@ -34,13 +35,14 @@ class PLATFORM_EXPORT String16 { String16(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeletedValue) { } bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue(); } operator WTF::String() const { return m_impl; } + operator WTF::StringView() const { return StringView(m_impl); } operator WebString() { return m_impl; } const WTF::String& impl() const { return m_impl; } String16 isolatedCopy() const { return String16(m_impl.isolatedCopy()); } ~String16() { } - static String16 number(int i) { return String::number(i); } + static String16 fromInteger(int i) { return String::number(i); } static String16 fromDouble(double number) { return Decimal::fromDouble(number).toString(); } static String16 fromDoubleFixedPrecision(double number, int precision) { return String::numberToStringFixedWidth(number, precision); } @@ -75,13 +77,14 @@ class PLATFORM_EXPORT String16 { class String16Builder { public: String16Builder() { } - void append(const String16& str) { m_impl.append(StringView(str)); }; + void append(const String16& str) { m_impl.append(str); }; void append(UChar c) { m_impl.append(c); }; void append(LChar c) { m_impl.append(c); }; void append(char c) { m_impl.append(c); }; void append(const UChar* c, size_t size) { m_impl.append(c, size); }; void append(const char* characters, unsigned length) { m_impl.append(characters, length); } void appendNumber(int number) { m_impl.appendNumber(number); } + void appendNumber(double number) { m_impl.appendNumber(number); } String16 toString() { return m_impl.toString(); } void reserveCapacity(unsigned newCapacity) { m_impl.reserveCapacity(newCapacity); } @@ -138,4 +141,14 @@ struct HashTraits : SimpleClassHashTraits { } // namespace WTF +namespace std { +template<> struct hash { + std::size_t operator()(const String16& string) const + { + return StringHash::hash(string.impl()); + } +}; + +} // namespace std + #endif // !defined(String16WTF_h) diff --git a/deps/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template similarity index 98% rename from deps/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template index 1aeef458f8d4ba..909fea4e71a7ff 100644 --- a/deps/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template @@ -140,7 +140,7 @@ public: {% for command in domain.commands %} {% if "redirect" in command %}{% continue %}{% endif %} {% if "handlers" in command and not ("renderer" in command["handlers"]) %}{% continue %}{% endif %} - m_dispatchMap.set("{{domain.domain}}.{{command.name}}", &DispatcherImpl::{{command.name}}); + m_dispatchMap["{{domain.domain}}.{{command.name}}"] = &DispatcherImpl::{{command.name}}; {% endfor %} } ~DispatcherImpl() override { } @@ -169,7 +169,7 @@ void DispatcherImpl::dispatch(int callId, const String16& method, std::unique_pt } protocol::ErrorSupport errors; - ((*this).*(*it->second))(callId, std::move(messageObject), &errors); + (this->*(it->second))(callId, std::move(messageObject), &errors); } {% for command in domain.commands %} diff --git a/deps/v8_inspector/platform/inspector_protocol/TypeBuilder_h.template b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_h.template similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/TypeBuilder_h.template rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/TypeBuilder_h.template diff --git a/deps/v8_inspector/platform/inspector_protocol/ValueConversions.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.cpp similarity index 100% rename from deps/v8_inspector/platform/inspector_protocol/ValueConversions.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.cpp diff --git a/deps/v8_inspector/platform/inspector_protocol/ValueConversions.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.h similarity index 95% rename from deps/v8_inspector/platform/inspector_protocol/ValueConversions.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.h index b82f04f588f7f1..dd7b2e78641054 100644 --- a/deps/v8_inspector/platform/inspector_protocol/ValueConversions.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/ValueConversions.h @@ -64,7 +64,7 @@ struct FromValue { static int parse(protocol::Value* value, ErrorSupport* errors) { int result = 0; - bool success = value ? value->asNumber(&result) : false; + bool success = value ? value->asInteger(&result) : false; if (!success) errors->addError("integer value expected"); return result; @@ -76,7 +76,7 @@ struct FromValue { static double parse(protocol::Value* value, ErrorSupport* errors) { double result = 0; - bool success = value ? value->asNumber(&result) : false; + bool success = value ? value->asDouble(&result) : false; if (!success) errors->addError("double value expected"); return result; @@ -112,8 +112,10 @@ struct FromValue { static std::unique_ptr parse(protocol::Value* value, ErrorSupport* errors) { bool success = !!value; - if (!success) + if (!success) { errors->addError("value expected"); + return nullptr; + } return value->clone(); } }; diff --git a/deps/v8_inspector/platform/inspector_protocol/Values.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.cpp similarity index 72% rename from deps/v8_inspector/platform/inspector_protocol/Values.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.cpp index 9cc1ca51bf484a..7d4ec242ae4c51 100644 --- a/deps/v8_inspector/platform/inspector_protocol/Values.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.cpp @@ -6,6 +6,8 @@ #include "platform/inspector_protocol/Parser.h" #include "platform/inspector_protocol/String16.h" + +#include #include namespace blink { @@ -75,12 +77,12 @@ bool Value::asBoolean(bool*) const return false; } -bool Value::asNumber(double*) const +bool Value::asDouble(double*) const { return false; } -bool Value::asNumber(int*) const +bool Value::asInteger(int*) const { return false; } @@ -117,42 +119,56 @@ bool FundamentalValue::asBoolean(bool* output) const return true; } -bool FundamentalValue::asNumber(double* output) const +bool FundamentalValue::asDouble(double* output) const { - if (type() != TypeNumber) - return false; - *output = m_doubleValue; - return true; + if (type() == TypeDouble) { + *output = m_doubleValue; + return true; + } + if (type() == TypeInteger) { + *output = m_integerValue; + return true; + } + return false; } -bool FundamentalValue::asNumber(int* output) const +bool FundamentalValue::asInteger(int* output) const { - if (type() != TypeNumber) + if (type() != TypeInteger) return false; - *output = static_cast(m_doubleValue); + *output = m_integerValue; return true; } void FundamentalValue::writeJSON(String16Builder* output) const { - DCHECK(type() == TypeBoolean || type() == TypeNumber); + DCHECK(type() == TypeBoolean || type() == TypeInteger || type() == TypeDouble); if (type() == TypeBoolean) { if (m_boolValue) output->append(trueString, 4); else output->append(falseString, 5); - } else if (type() == TypeNumber) { + } else if (type() == TypeDouble) { if (!std::isfinite(m_doubleValue)) { output->append(nullString, 4); return; } output->append(String16::fromDouble(m_doubleValue)); + } else if (type() == TypeInteger) { + output->append(String16::fromInteger(m_integerValue)); } } std::unique_ptr FundamentalValue::clone() const { - return type() == TypeNumber ? FundamentalValue::create(m_doubleValue) : FundamentalValue::create(m_boolValue); + switch (type()) { + case TypeDouble: return FundamentalValue::create(m_doubleValue); + case TypeInteger: return FundamentalValue::create(m_integerValue); + case TypeBoolean: return FundamentalValue::create(m_boolValue); + default: + NOTREACHED(); + } + return nullptr; } bool StringValue::asString(String16* output) const @@ -181,7 +197,12 @@ void DictionaryValue::setBoolean(const String16& name, bool value) setValue(name, FundamentalValue::create(value)); } -void DictionaryValue::setNumber(const String16& name, double value) +void DictionaryValue::setInteger(const String16& name, int value) +{ + setValue(name, FundamentalValue::create(value)); +} + +void DictionaryValue::setDouble(const String16& name, double value) { setValue(name, FundamentalValue::create(value)); } @@ -193,23 +214,17 @@ void DictionaryValue::setString(const String16& name, const String16& value) void DictionaryValue::setValue(const String16& name, std::unique_ptr value) { - DCHECK(value); - if (m_data.set(name, std::move(value))) - m_order.append(name); + set(name, value); } void DictionaryValue::setObject(const String16& name, std::unique_ptr value) { - DCHECK(value); - if (m_data.set(name, std::move(value))) - m_order.append(name); + set(name, value); } void DictionaryValue::setArray(const String16& name, std::unique_ptr value) { - DCHECK(value); - if (m_data.set(name, std::move(value))) - m_order.append(name); + set(name, value); } bool DictionaryValue::getBoolean(const String16& name, bool* output) const @@ -220,6 +235,22 @@ bool DictionaryValue::getBoolean(const String16& name, bool* output) const return value->asBoolean(output); } +bool DictionaryValue::getInteger(const String16& name, int* output) const +{ + Value* value = get(name); + if (!value) + return false; + return value->asInteger(output); +} + +bool DictionaryValue::getDouble(const String16& name, double* output) const +{ + Value* value = get(name); + if (!value) + return false; + return value->asDouble(output); +} + bool DictionaryValue::getString(const String16& name, String16* output) const { protocol::Value* value = get(name); @@ -243,13 +274,13 @@ protocol::Value* DictionaryValue::get(const String16& name) const Dictionary::const_iterator it = m_data.find(name); if (it == m_data.end()) return nullptr; - return it->second; + return it->second.get(); } DictionaryValue::Entry DictionaryValue::at(size_t index) const { - String16 key = m_order[index]; - return std::make_pair(key, m_data.get(key)); + const String16 key = m_order[index]; + return std::make_pair(key, m_data.find(key)->second.get()); } bool DictionaryValue::booleanProperty(const String16& name, bool defaultValue) const @@ -259,22 +290,24 @@ bool DictionaryValue::booleanProperty(const String16& name, bool defaultValue) c return result; } -double DictionaryValue::numberProperty(const String16& name, double defaultValue) const +int DictionaryValue::integerProperty(const String16& name, int defaultValue) const +{ + int result = defaultValue; + getInteger(name, &result); + return result; +} + +double DictionaryValue::doubleProperty(const String16& name, double defaultValue) const { double result = defaultValue; - getNumber(name, &result); + getDouble(name, &result); return result; } void DictionaryValue::remove(const String16& name) { - m_data.remove(name); - for (size_t i = 0; i < m_order.size(); ++i) { - if (m_order[i] == name) { - m_order.remove(i); - break; - } - } + m_data.erase(name); + m_order.erase(std::remove(m_order.begin(), m_order.end(), name), m_order.end()); } void DictionaryValue::writeJSON(String16Builder* output) const @@ -297,9 +330,9 @@ std::unique_ptr DictionaryValue::clone() const std::unique_ptr result = DictionaryValue::create(); for (size_t i = 0; i < m_order.size(); ++i) { String16 key = m_order[i]; - Value* value = m_data.get(key); - DCHECK(value); - result->setValue(key, value->clone()); + Dictionary::const_iterator value = m_data.find(key); + DCHECK(value != m_data.cend() && value->second); + result->setValue(key, value->second->clone()); } return std::move(result); } @@ -316,10 +349,12 @@ ListValue::~ListValue() void ListValue::writeJSON(String16Builder* output) const { output->append('['); - for (Vector>::const_iterator it = m_data.begin(); it != m_data.end(); ++it) { - if (it != m_data.begin()) + bool first = true; + for (const std::unique_ptr& value : m_data) { + if (!first) output->append(','); - (*it)->writeJSON(output); + value->writeJSON(output); + first = false; } output->append(']'); } @@ -327,8 +362,8 @@ void ListValue::writeJSON(String16Builder* output) const std::unique_ptr ListValue::clone() const { std::unique_ptr result = ListValue::create(); - for (Vector>::const_iterator it = m_data.begin(); it != m_data.end(); ++it) - result->pushValue((*it)->clone()); + for (const std::unique_ptr& value : m_data) + result->pushValue(value->clone()); return std::move(result); } @@ -340,13 +375,13 @@ ListValue::ListValue() void ListValue::pushValue(std::unique_ptr value) { DCHECK(value); - m_data.append(std::move(value)); + m_data.push_back(std::move(value)); } protocol::Value* ListValue::at(size_t index) { DCHECK_LT(index, m_data.size()); - return m_data[index]; + return m_data[index].get(); } } // namespace protocol diff --git a/deps/v8_inspector/platform/inspector_protocol/Values.h b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.h similarity index 82% rename from deps/v8_inspector/platform/inspector_protocol/Values.h rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.h index e4a719286fb67d..07a2cac9249f47 100644 --- a/deps/v8_inspector/platform/inspector_protocol/Values.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/Values.h @@ -10,6 +10,8 @@ #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" +#include + namespace blink { namespace protocol { @@ -32,7 +34,8 @@ class PLATFORM_EXPORT Value { enum ValueType { TypeNull = 0, TypeBoolean, - TypeNumber, + TypeInteger, + TypeDouble, TypeString, TypeObject, TypeArray @@ -43,8 +46,8 @@ class PLATFORM_EXPORT Value { bool isNull() const { return m_type == TypeNull; } virtual bool asBoolean(bool* output) const; - virtual bool asNumber(double* output) const; - virtual bool asNumber(int* output) const; + virtual bool asDouble(double* output) const; + virtual bool asInteger(int* output) const; virtual bool asString(String16* output) const; String16 toJSONString() const; @@ -80,19 +83,20 @@ class PLATFORM_EXPORT FundamentalValue : public Value { } bool asBoolean(bool* output) const override; - bool asNumber(double* output) const override; - bool asNumber(int* output) const override; + bool asDouble(double* output) const override; + bool asInteger(int* output) const override; void writeJSON(String16Builder* output) const override; std::unique_ptr clone() const override; private: explicit FundamentalValue(bool value) : Value(TypeBoolean), m_boolValue(value) { } - explicit FundamentalValue(int value) : Value(TypeNumber), m_doubleValue((double)value) { } - explicit FundamentalValue(double value) : Value(TypeNumber), m_doubleValue(value) { } + explicit FundamentalValue(int value) : Value(TypeInteger), m_integerValue(value) { } + explicit FundamentalValue(double value) : Value(TypeDouble), m_doubleValue(value) { } union { bool m_boolValue; double m_doubleValue; + int m_integerValue; }; }; @@ -145,20 +149,16 @@ class PLATFORM_EXPORT DictionaryValue : public Value { size_t size() const { return m_data.size(); } void setBoolean(const String16& name, bool); - void setNumber(const String16& name, double); + void setInteger(const String16& name, int); + void setDouble(const String16& name, double); void setString(const String16& name, const String16&); void setValue(const String16& name, std::unique_ptr); void setObject(const String16& name, std::unique_ptr); void setArray(const String16& name, std::unique_ptr); bool getBoolean(const String16& name, bool* output) const; - template bool getNumber(const String16& name, T* output) const - { - Value* value = get(name); - if (!value) - return false; - return value->asNumber(output); - } + bool getInteger(const String16& name, int* output) const; + bool getDouble(const String16& name, double* output) const; bool getString(const String16& name, String16* output) const; DictionaryValue* getObject(const String16& name) const; @@ -167,17 +167,27 @@ class PLATFORM_EXPORT DictionaryValue : public Value { Entry at(size_t index) const; bool booleanProperty(const String16& name, bool defaultValue) const; - double numberProperty(const String16& name, double defaultValue) const; + int integerProperty(const String16& name, int defaultValue) const; + double doubleProperty(const String16& name, double defaultValue) const; void remove(const String16& name); ~DictionaryValue() override; private: DictionaryValue(); + template + void set(const String16& key, std::unique_ptr& value) + { + DCHECK(value); + bool isNew = m_data.find(key) == m_data.end(); + m_data[key] = std::move(value); + if (isNew) + m_order.push_back(key); + } using Dictionary = protocol::HashMap>; Dictionary m_data; - protocol::Vector m_order; + std::vector m_order; }; class PLATFORM_EXPORT ListValue : public Value { @@ -211,7 +221,7 @@ class PLATFORM_EXPORT ListValue : public Value { private: ListValue(); - protocol::Vector> m_data; + std::vector> m_data; }; } // namespace protocol diff --git a/deps/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version similarity index 99% rename from deps/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version rename to deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version index 65738d6f38be9c..838a3ed2dd815a 100755 --- a/deps/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version +++ b/deps/v8_inspector/third_party/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version @@ -4,7 +4,7 @@ # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: -# +# # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. -# +# # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -28,7 +28,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Inspector protocol validator. -# +# # Tests that subsequent protocol changes are not breaking backwards compatibility. # Following violations are reported: # @@ -39,7 +39,7 @@ # - Event has been removed # - Required event parameter was removed or changed to optional # - Parameter type has changed. -# +# # For the parameters with composite types the above checks are also applied # recursively to every property of the type. # @@ -197,7 +197,7 @@ def extract_type(typed_object, types_map, errors): ref = typed_object["$ref"] if not ref in types_map: errors.append("Can not resolve type: %s" % ref) - types_map[ref] = { "id": "", "type": "object" } + types_map[ref] = { "id": "", "type": "object" } return types_map[ref] diff --git a/deps/v8_inspector/platform/v8_inspector/Atomics.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/Atomics.h similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/Atomics.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/Atomics.h diff --git a/deps/v8_inspector/platform/v8_inspector/DebuggerScript.js b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/DebuggerScript.js similarity index 98% rename from deps/v8_inspector/platform/v8_inspector/DebuggerScript.js rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/DebuggerScript.js index 85d214e06efad6..5b534f322160f3 100644 --- a/deps/v8_inspector/platform/v8_inspector/DebuggerScript.js +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/DebuggerScript.js @@ -92,9 +92,9 @@ DebuggerScript.getFunctionScopes = function(fun) /** * @param {Object} object - * @return {?GeneratorObjectDetails} + * @return {?RawLocation} */ -DebuggerScript.getGeneratorObjectDetails = function(object) +DebuggerScript.getGeneratorObjectLocation = function(object) { var mirror = MakeMirror(object, true /* transient */); if (!mirror.isGenerator()) @@ -103,21 +103,16 @@ DebuggerScript.getGeneratorObjectDetails = function(object) var funcMirror = generatorMirror.func(); if (!funcMirror.resolved()) return null; - var result = { - "function": funcMirror.value(), - "functionName": funcMirror.debugName(), - "status": generatorMirror.status() - }; - var script = funcMirror.script(); var location = generatorMirror.sourceLocation() || funcMirror.sourceLocation(); + var script = funcMirror.script(); if (script && location) { - result["location"] = { - "scriptId": String(script.id()), - "lineNumber": location.line, - "columnNumber": location.column + return { + scriptId: "" + script.id(), + lineNumber: location.line, + columnNumber: location.column }; } - return result; + return null; } /** diff --git a/deps/v8_inspector/platform/v8_inspector/InjectedScript.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.cpp similarity index 92% rename from deps/v8_inspector/platform/v8_inspector/InjectedScript.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.cpp index 868fdeabb4a10b..302b635ed47a1b 100644 --- a/deps/v8_inspector/platform/v8_inspector/InjectedScript.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.cpp @@ -47,13 +47,9 @@ #include "platform/v8_inspector/V8StringUtil.h" #include "platform/v8_inspector/public/V8Debugger.h" #include "platform/v8_inspector/public/V8DebuggerClient.h" -#include "platform/v8_inspector/public/V8ToProtocolValue.h" using blink::protocol::Array; using blink::protocol::Debugger::CallFrame; -using blink::protocol::Debugger::CollectionEntry; -using blink::protocol::Debugger::FunctionDetails; -using blink::protocol::Debugger::GeneratorObjectDetails; using blink::protocol::Runtime::PropertyDescriptor; using blink::protocol::Runtime::InternalPropertyDescriptor; using blink::protocol::Runtime::RemoteObject; @@ -149,7 +145,7 @@ void InjectedScript::releaseObject(const String16& objectId) if (!object) return; int boundId = 0; - if (!object->getNumber("id", &boundId)) + if (!object->getInteger("id", &boundId)) return; m_native->unbind(boundId); } @@ -187,7 +183,6 @@ bool InjectedScript::wrapPropertyInArray(ErrorString* errorString, v8::Localdebugger(), m_context->context(), v8Value(), "wrapObjectsInArray"); function.appendArgument(array); function.appendArgument(groupName); - function.appendArgument(canAccessInspectedWindow()); function.appendArgument(forceValueType); function.appendArgument(generatePreview); bool hadException = false; @@ -213,7 +207,6 @@ v8::MaybeLocal InjectedScript::wrapValue(ErrorString* errorString, v8 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value(), "wrapObject"); function.appendArgument(value); function.appendArgument(groupName); - function.appendArgument(canAccessInspectedWindow()); function.appendArgument(forceValueType); function.appendArgument(generatePreview); bool hadException = false; @@ -227,7 +220,6 @@ std::unique_ptr InjectedScript::wrapTable(v8::L { v8::HandleScope handles(m_context->isolate()); V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value(), "wrapTable"); - function.appendArgument(canAccessInspectedWindow()); function.appendArgument(table); if (columns.IsEmpty()) function.appendArgument(false); @@ -271,14 +263,6 @@ void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) DCHECK(!hadException); } -bool InjectedScript::canAccessInspectedWindow() const -{ - v8::Local callingContext = m_context->isolate()->GetCallingContext(); - if (callingContext.IsEmpty()) - return true; - return m_context->debugger()->client()->callingContextCanAccessContext(callingContext, m_context->context()); -} - v8::Local InjectedScript::v8Value() const { return m_value.Get(m_context->isolate()); @@ -322,20 +306,16 @@ v8::MaybeLocal InjectedScript::resolveCallArgument(ErrorString* error std::unique_ptr InjectedScript::createExceptionDetails(v8::Local message) { - std::unique_ptr exceptionDetailsObject = protocol::Runtime::ExceptionDetails::create().setText(toProtocolString(message->Get())).build(); - exceptionDetailsObject->setUrl(toProtocolStringWithTypeCheck(message->GetScriptResourceName())); - exceptionDetailsObject->setScriptId(String16::number(message->GetScriptOrigin().ScriptID()->Value())); - - v8::Maybe lineNumber = message->GetLineNumber(m_context->context()); - if (lineNumber.IsJust()) - exceptionDetailsObject->setLine(lineNumber.FromJust()); - v8::Maybe columnNumber = message->GetStartColumn(m_context->context()); - if (columnNumber.IsJust()) - exceptionDetailsObject->setColumn(columnNumber.FromJust()); + std::unique_ptr exceptionDetailsObject = protocol::Runtime::ExceptionDetails::create() + .setText(toProtocolString(message->Get())) + .setScriptId(String16::fromInteger(message->GetScriptOrigin().ScriptID()->Value())) + .setLineNumber(message->GetLineNumber(m_context->context()).FromMaybe(1) - 1) + .setColumnNumber(message->GetStartColumn(m_context->context()).FromMaybe(0)) + .build(); v8::Local stackTrace = message->GetStackTrace(); if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) - exceptionDetailsObject->setStack(m_context->debugger()->createStackTrace(stackTrace)->buildInspectorObject()); + exceptionDetailsObject->setStackTrace(m_context->debugger()->createStackTrace(stackTrace)->buildInspectorObject()); return exceptionDetailsObject; } @@ -414,7 +394,7 @@ void InjectedScript::Scope::ignoreExceptionsAndMuteConsole() { DCHECK(!m_ignoreExceptionsAndMuteConsole); m_ignoreExceptionsAndMuteConsole = true; - m_debugger->client()->muteConsole(); + m_debugger->client()->muteWarningsAndDeprecations(m_contextGroupId); m_previousPauseOnExceptionsState = setPauseOnExceptionsState(V8DebuggerImpl::DontPauseOnExceptions); } @@ -448,7 +428,7 @@ InjectedScript::Scope::~Scope() { if (m_ignoreExceptionsAndMuteConsole) { setPauseOnExceptionsState(m_previousPauseOnExceptionsState); - m_debugger->client()->unmuteConsole(); + m_debugger->client()->unmuteWarningsAndDeprecations(m_contextGroupId); } if (m_userGesture) m_debugger->client()->endUserGesture(); diff --git a/deps/v8_inspector/platform/v8_inspector/InjectedScript.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.h similarity index 99% rename from deps/v8_inspector/platform/v8_inspector/InjectedScript.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.h index 7dae28aba92cce..ab847ee0412906 100644 --- a/deps/v8_inspector/platform/v8_inspector/InjectedScript.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScript.h @@ -159,7 +159,6 @@ class InjectedScript final { private: InjectedScript(InspectedContext*, v8::Local, std::unique_ptr); - bool canAccessInspectedWindow() const; v8::Local v8Value() const; v8::MaybeLocal wrapValue(ErrorString*, v8::Local, const String16& groupName, bool forceValueType, bool generatePreview) const; v8::Local commandLineAPI(); diff --git a/deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptNative.cpp similarity index 79% rename from deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptNative.cpp index 89e48fcbf13cc4..4f0eff93c41aaa 100644 --- a/deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptNative.cpp @@ -43,20 +43,21 @@ int InjectedScriptNative::bind(v8::Local value, const String16& group if (m_lastBoundObjectId <= 0) m_lastBoundObjectId = 1; int id = m_lastBoundObjectId++; - m_idToWrappedObject.set(id, wrapUnique(new v8::Global(m_isolate, value))); + m_idToWrappedObject[id] = wrapUnique(new v8::Global(m_isolate, value)); addObjectToGroup(id, groupName); return id; } void InjectedScriptNative::unbind(int id) { - m_idToWrappedObject.remove(id); - m_idToObjectGroupName.remove(id); + m_idToWrappedObject.erase(id); + m_idToObjectGroupName.erase(id); } v8::Local InjectedScriptNative::objectForId(int id) { - return m_idToWrappedObject.contains(id) ? m_idToWrappedObject.get(id)->Get(m_isolate) : v8::Local(); + auto iter = m_idToWrappedObject.find(id); + return iter != m_idToWrappedObject.end() ? iter->second->Get(m_isolate) : v8::Local(); } void InjectedScriptNative::addObjectToGroup(int objectId, const String16& groupName) @@ -65,13 +66,8 @@ void InjectedScriptNative::addObjectToGroup(int objectId, const String16& groupN return; if (objectId <= 0) return; - m_idToObjectGroupName.set(objectId, groupName); - auto it = m_nameToObjectGroup.find(groupName); - if (it == m_nameToObjectGroup.end()) { - m_nameToObjectGroup.set(groupName, protocol::Vector()); - it = m_nameToObjectGroup.find(groupName); - } - it->second->append(objectId); + m_idToObjectGroupName[objectId] = groupName; + m_nameToObjectGroup[groupName].push_back(objectId); // Creates an empty vector if key is not there } void InjectedScriptNative::releaseObjectGroup(const String16& groupName) @@ -81,16 +77,18 @@ void InjectedScriptNative::releaseObjectGroup(const String16& groupName) NameToObjectGroup::iterator groupIt = m_nameToObjectGroup.find(groupName); if (groupIt == m_nameToObjectGroup.end()) return; - for (int id : *groupIt->second) + for (int id : groupIt->second) unbind(id); - m_nameToObjectGroup.remove(groupName); + m_nameToObjectGroup.erase(groupIt); } String16 InjectedScriptNative::groupName(int objectId) const { if (objectId <= 0) return String16(); - return m_idToObjectGroupName.get(objectId); + IdToObjectGroupName::const_iterator iterator = m_idToObjectGroupName.find(objectId); + return iterator != m_idToObjectGroupName.end() ? iterator->second : String16(); } } // namespace blink + diff --git a/deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptNative.h similarity index 93% rename from deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptNative.h index 63d2a30f3c3165..c8082fe95edd61 100644 --- a/deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptNative.h @@ -10,6 +10,8 @@ #include "platform/inspector_protocol/String16.h" #include +#include + namespace blink { class InjectedScriptNative final { @@ -35,7 +37,7 @@ class InjectedScriptNative final { protocol::HashMap>> m_idToWrappedObject; typedef protocol::HashMap IdToObjectGroupName; IdToObjectGroupName m_idToObjectGroupName; - typedef protocol::HashMap> NameToObjectGroup; + typedef protocol::HashMap> NameToObjectGroup; NameToObjectGroup m_nameToObjectGroup; }; diff --git a/deps/v8_inspector/platform/v8_inspector/InjectedScriptSource.js b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptSource.js similarity index 91% rename from deps/v8_inspector/platform/v8_inspector/InjectedScriptSource.js rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptSource.js index 0e0c4f8d28065b..d2b3b2725ee665 100644 --- a/deps/v8_inspector/platform/v8_inspector/InjectedScriptSource.js +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InjectedScriptSource.js @@ -199,6 +199,20 @@ InjectedScript.primitiveTypes = { __proto__: null } +/** + * @type {!Map} + * @const + */ +InjectedScript.closureTypes = new Map([ + ["local", "Local"], + ["closure", "Closure"], + ["catch", "Catch"], + ["block", "Block"], + ["script", "Script"], + ["with", "With Block"], + ["global", "Global"] +]); + InjectedScript.prototype = { /** * @param {*} object @@ -210,75 +224,61 @@ InjectedScript.prototype = { return InjectedScript.primitiveTypes[typeof object] && !this._isHTMLAllCollection(object); }, + /** + * @param {*} object + * @return {boolean} + */ + _shouldPassByValue: function(object) + { + return typeof object === "object" && InjectedScriptHost.subtype(object) === "internal#location"; + }, + /** * @param {*} object * @param {string} groupName - * @param {boolean} canAccessInspectedGlobalObject * @param {boolean} forceValueType * @param {boolean} generatePreview * @return {!RuntimeAgent.RemoteObject} */ - wrapObject: function(object, groupName, canAccessInspectedGlobalObject, forceValueType, generatePreview) + wrapObject: function(object, groupName, forceValueType, generatePreview) { - if (canAccessInspectedGlobalObject) - return this._wrapObject(object, groupName, forceValueType, generatePreview); - return this._fallbackWrapper(object); + return this._wrapObject(object, groupName, forceValueType, generatePreview); }, /** * @param {!Array} array * @param {string} property * @param {string} groupName - * @param {boolean} canAccessInspectedGlobalObject * @param {boolean} forceValueType * @param {boolean} generatePreview */ - wrapPropertyInArray: function(array, property, groupName, canAccessInspectedGlobalObject, forceValueType, generatePreview) + wrapPropertyInArray: function(array, property, groupName, forceValueType, generatePreview) { for (var i = 0; i < array.length; ++i) { if (typeof array[i] === "object" && property in array[i]) - array[i][property] = this.wrapObject(array[i][property], groupName, canAccessInspectedGlobalObject, forceValueType, generatePreview); + array[i][property] = this.wrapObject(array[i][property], groupName, forceValueType, generatePreview); } }, /** * @param {!Array<*>} array * @param {string} groupName - * @param {boolean} canAccessInspectedGlobalObject * @param {boolean} forceValueType * @param {boolean} generatePreview */ - wrapObjectsInArray: function(array, groupName, canAccessInspectedGlobalObject, forceValueType, generatePreview) + wrapObjectsInArray: function(array, groupName, forceValueType, generatePreview) { for (var i = 0; i < array.length; ++i) - array[i] = this.wrapObject(array[i], groupName, canAccessInspectedGlobalObject, forceValueType, generatePreview); - }, - - /** - * @param {*} object - * @return {!RuntimeAgent.RemoteObject} - */ - _fallbackWrapper: function(object) - { - var result = { __proto__: null }; - result.type = typeof object; - if (this.isPrimitiveValue(object)) - result.value = object; - else - result.description = toString(object); - return /** @type {!RuntimeAgent.RemoteObject} */ (result); + array[i] = this.wrapObject(array[i], groupName, forceValueType, generatePreview); }, /** - * @param {boolean} canAccessInspectedGlobalObject * @param {!Object} table * @param {!Array.|string|boolean} columns * @return {!RuntimeAgent.RemoteObject} */ - wrapTable: function(canAccessInspectedGlobalObject, table, columns) + wrapTable: function(table, columns) { - if (!canAccessInspectedGlobalObject) - return this._fallbackWrapper(table); var columnNames = null; if (typeof columns === "string") columns = [columns]; @@ -338,10 +338,20 @@ InjectedScript.prototype = { */ getProperties: function(object, objectGroupName, ownProperties, accessorPropertiesOnly, generatePreview) { + var subtype = this._subtype(object); + if (subtype === "internal#scope") { + // Internally, scope contains object with scope variables and additional information like type, + // we use additional information for preview and would like to report variables as scope + // properties. + object = object.object; + } + var descriptors = []; var iter = this._propertyDescriptors(object, ownProperties, accessorPropertiesOnly, undefined); // Go over properties, wrap object values. for (var descriptor of iter) { + if (subtype === "internal#scopeList" && descriptor.name === "length") + continue; if ("get" in descriptor) descriptor.get = this._wrapObject(descriptor.get, objectGroupName); if ("set" in descriptor) @@ -635,9 +645,34 @@ InjectedScript.prototype = { } } + if (subtype === "internal#entry") { + if ("key" in obj) + return "{" + this._describeIncludingPrimitives(obj.key) + " => " + this._describeIncludingPrimitives(obj.value) + "}"; + return this._describeIncludingPrimitives(obj.value); + } + + if (subtype === "internal#scopeList") + return "Scopes[" + obj.length + "]"; + + if (subtype === "internal#scope") + return (InjectedScript.closureTypes.get(obj.type) || "Unknown") + (obj.name ? " (" + obj.name + ")" : ""); + return className; }, + /** + * @param {*} value + * @return {string} + */ + _describeIncludingPrimitives: function(value) + { + if (typeof value === "string") + return "\"" + value.replace(/\n/g, "\u21B5") + "\""; + if (value === null) + return "" + value; + return this.isPrimitiveValue(value) ? toStringDescription(value) : (this._describe(value) || ""); + }, + /** * @param {boolean} enabled */ @@ -697,6 +732,13 @@ InjectedScript.RemoteObject = function(object, objectGroupName, doNotBind, force return; } + if (injectedScript._shouldPassByValue(object)) { + this.value = object; + this.subtype = injectedScript._subtype(object); + this.description = injectedScript._describeIncludingPrimitives(object); + return; + } + object = /** @type {!Object} */ (object); if (!doNotBind) @@ -827,7 +869,12 @@ InjectedScript.RemoteObject.prototype = { // Add internal properties to preview. var rawInternalProperties = InjectedScriptHost.getInternalProperties(object) || []; var internalProperties = []; + var entries = null; for (var i = 0; i < rawInternalProperties.length; i += 2) { + if (rawInternalProperties[i] === "[[Entries]]") { + entries = /** @type {!Array<*>} */(rawInternalProperties[i + 1]); + continue; + } push(internalProperties, { name: rawInternalProperties[i], value: rawInternalProperties[i + 1], @@ -839,7 +886,7 @@ InjectedScript.RemoteObject.prototype = { this._appendPropertyDescriptors(preview, internalProperties, propertiesThreshold, secondLevelKeys, isTable); if (this.subtype === "map" || this.subtype === "set" || this.subtype === "iterator") - this._appendEntriesPreview(object, preview, skipEntriesPreview); + this._appendEntriesPreview(entries, preview, skipEntriesPreview); } catch (e) {} @@ -947,13 +994,12 @@ InjectedScript.RemoteObject.prototype = { }, /** - * @param {!Object} object + * @param {?Array<*>} entries * @param {!RuntimeAgent.ObjectPreview} preview * @param {boolean=} skipEntriesPreview */ - _appendEntriesPreview: function(object, preview, skipEntriesPreview) + _appendEntriesPreview: function(entries, preview, skipEntriesPreview) { - var entries = InjectedScriptHost.collectionEntries(object); if (!entries) return; if (skipEntriesPreview) { diff --git a/deps/v8_inspector/platform/v8_inspector/InspectedContext.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.cpp similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/InspectedContext.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.cpp diff --git a/deps/v8_inspector/platform/v8_inspector/InspectedContext.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.h similarity index 97% rename from deps/v8_inspector/platform/v8_inspector/InspectedContext.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.h index 284679ddc0ca10..ecff5e4012f008 100644 --- a/deps/v8_inspector/platform/v8_inspector/InspectedContext.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/InspectedContext.h @@ -6,7 +6,7 @@ #define InspectedContext_h #include "platform/inspector_protocol/Allocator.h" -#include "platform/inspector_protocol/Collections.h" +#include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" #include diff --git a/deps/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.cpp similarity index 92% rename from deps/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.cpp index c72cadcafe2612..8bcc475f401d72 100644 --- a/deps/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.cpp @@ -95,7 +95,7 @@ v8::Local JavaScriptCallFrame::details() const v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Local callFrame = v8::Local::New(m_isolate, m_callFrame); v8::Local func = v8::Local::Cast(callFrame->Get(toV8StringInternalized(m_isolate, "details"))); - return v8::Local::Cast(func->Call(m_isolate->GetCurrentContext(), callFrame, 0, nullptr).ToLocalChecked()); + return v8::Local::Cast(func->Call(m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr).ToLocalChecked()); } v8::MaybeLocal JavaScriptCallFrame::evaluate(v8::Local expression) @@ -103,7 +103,7 @@ v8::MaybeLocal JavaScriptCallFrame::evaluate(v8::Local exp v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kRunMicrotasks); v8::Local callFrame = v8::Local::New(m_isolate, m_callFrame); v8::Local evalFunction = v8::Local::Cast(callFrame->Get(toV8StringInternalized(m_isolate, "evaluate"))); - return evalFunction->Call(m_isolate->GetCurrentContext(), callFrame, 1, &expression); + return evalFunction->Call(m_debuggerContext.Get(m_isolate), callFrame, 1, &expression); } v8::MaybeLocal JavaScriptCallFrame::restart() @@ -112,7 +112,7 @@ v8::MaybeLocal JavaScriptCallFrame::restart() v8::Local callFrame = v8::Local::New(m_isolate, m_callFrame); v8::Local restartFunction = v8::Local::Cast(callFrame->Get(toV8StringInternalized(m_isolate, "restart"))); v8::Debug::SetLiveEditEnabled(m_isolate, true); - v8::MaybeLocal result = restartFunction->Call(m_isolate->GetCurrentContext(), callFrame, 0, nullptr); + v8::MaybeLocal result = restartFunction->Call(m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr); v8::Debug::SetLiveEditEnabled(m_isolate, false); return result; } @@ -127,7 +127,7 @@ v8::MaybeLocal JavaScriptCallFrame::setVariableValue(int scopeNumber, variableName, newValue }; - return setVariableValueFunction->Call(m_isolate->GetCurrentContext(), callFrame, PROTOCOL_ARRAY_LENGTH(argv), argv); + return setVariableValueFunction->Call(m_debuggerContext.Get(m_isolate), callFrame, PROTOCOL_ARRAY_LENGTH(argv), argv); } } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.h similarity index 96% rename from deps/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.h index 6f9693522eaba9..959f8172ee31da 100644 --- a/deps/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.h @@ -36,6 +36,8 @@ #include "platform/inspector_protocol/String16.h" #include +#include + namespace blink { class JavaScriptCallFrame { @@ -67,7 +69,7 @@ class JavaScriptCallFrame { v8::Global m_callFrame; }; -using JavaScriptCallFrames = protocol::Vector>; +using JavaScriptCallFrames = std::vector>; } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/OWNERS b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/OWNERS similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/OWNERS rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/OWNERS diff --git a/deps/v8_inspector/platform/v8_inspector/RemoteObjectId.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/RemoteObjectId.cpp similarity index 85% rename from deps/v8_inspector/platform/v8_inspector/RemoteObjectId.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/RemoteObjectId.cpp index 9a2a6c00886e96..e9aaf26d51e028 100644 --- a/deps/v8_inspector/platform/v8_inspector/RemoteObjectId.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/RemoteObjectId.cpp @@ -19,7 +19,7 @@ std::unique_ptr RemoteObjectIdBase::parseInjectedScri return nullptr; std::unique_ptr parsedObjectId(protocol::DictionaryValue::cast(parsedValue.release())); - bool success = parsedObjectId->getNumber("injectedScriptId", &m_injectedScriptId); + bool success = parsedObjectId->getInteger("injectedScriptId", &m_injectedScriptId); if (success) return parsedObjectId; return nullptr; @@ -36,7 +36,7 @@ std::unique_ptr RemoteObjectId::parse(ErrorString* errorString, return nullptr; } - bool success = parsedObjectId->getNumber("id", &result->m_id); + bool success = parsedObjectId->getInteger("id", &result->m_id); if (!success) { *errorString = "Invalid remote object id"; return nullptr; @@ -55,7 +55,7 @@ std::unique_ptr RemoteCallFrameId::parse(ErrorString* errorSt return nullptr; } - bool success = parsedObjectId->getNumber("ordinal", &result->m_frameOrdinal); + bool success = parsedObjectId->getInteger("ordinal", &result->m_frameOrdinal); if (!success) { *errorString = "Invalid call frame id"; return nullptr; @@ -66,7 +66,7 @@ std::unique_ptr RemoteCallFrameId::parse(ErrorString* errorSt String16 RemoteCallFrameId::serialize(int injectedScriptId, int frameOrdinal) { - return "{\"ordinal\":" + String16::number(frameOrdinal) + ",\"injectedScriptId\":" + String16::number(injectedScriptId) + "}"; + return "{\"ordinal\":" + String16::fromInteger(frameOrdinal) + ",\"injectedScriptId\":" + String16::fromInteger(injectedScriptId) + "}"; } } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/RemoteObjectId.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/RemoteObjectId.h similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/RemoteObjectId.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/RemoteObjectId.h diff --git a/deps/v8_inspector/platform/v8_inspector/ScriptBreakpoint.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/ScriptBreakpoint.h similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/ScriptBreakpoint.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/ScriptBreakpoint.h diff --git a/deps/v8_inspector/platform/v8_inspector/V8Compat.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Compat.h similarity index 97% rename from deps/v8_inspector/platform/v8_inspector/V8Compat.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Compat.h index 30492b3af7a8e9..0f5b12cbb6cb07 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8Compat.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Compat.h @@ -23,6 +23,6 @@ class V8_EXPORT MicrotasksScope { } // namespace v8 -#endif // V8_MAJOR_VERSION < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#endif // V8_MAJOR_VERSION < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 1) #endif // V8Compat_h diff --git a/deps/v8_inspector/platform/v8_inspector/V8Console.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Console.cpp similarity index 87% rename from deps/v8_inspector/platform/v8_inspector/V8Console.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Console.cpp index d10b326d151f67..f7e142deeadbf3 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8Console.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Console.cpp @@ -9,6 +9,7 @@ #include "platform/v8_inspector/InjectedScript.h" #include "platform/v8_inspector/InspectedContext.h" #include "platform/v8_inspector/V8Compat.h" +#include "platform/v8_inspector/V8ConsoleMessage.h" #include "platform/v8_inspector/V8DebuggerAgentImpl.h" #include "platform/v8_inspector/V8DebuggerImpl.h" #include "platform/v8_inspector/V8InspectorSessionImpl.h" @@ -16,8 +17,6 @@ #include "platform/v8_inspector/V8RuntimeAgentImpl.h" #include "platform/v8_inspector/V8StackTraceImpl.h" #include "platform/v8_inspector/V8StringUtil.h" -#include "platform/v8_inspector/public/ConsoleAPITypes.h" -#include "platform/v8_inspector/public/ConsoleTypes.h" #include "platform/v8_inspector/public/V8DebuggerClient.h" namespace blink { @@ -77,26 +76,48 @@ class ConsoleHelper { return m_debuggerClient; } - void addMessage(MessageType type, MessageLevel level, String16 emptyText, int skipArgumentCount) + void reportCall(ConsoleAPIType type) { - if (emptyText.isEmpty() && !m_info.Length()) + if (!m_info.Length()) return; - if (V8DebuggerClient* debuggerClient = ensureDebuggerClient()) - debuggerClient->reportMessageToConsole(m_context, type, level, m_info.Length() <= skipArgumentCount ? emptyText : String16(), &m_info, skipArgumentCount); + std::vector> arguments; + for (int i = 0; i < m_info.Length(); ++i) + arguments.push_back(m_info[i]); + reportCall(type, arguments); } - void addMessage(MessageType type, MessageLevel level, const String16& message) + void reportCallWithDefaultArgument(ConsoleAPIType type, const String16& message) { - if (V8DebuggerClient* debuggerClient = ensureDebuggerClient()) - debuggerClient->reportMessageToConsole(m_context, type, level, message, nullptr, 0 /* skipArgumentsCount */); + std::vector> arguments; + for (int i = 0; i < m_info.Length(); ++i) + arguments.push_back(m_info[i]); + if (!m_info.Length()) + arguments.push_back(toV8String(m_isolate, message)); + reportCall(type, arguments); } - void addDeprecationMessage(const char* id, const String16& message) + void reportCallWithArgument(ConsoleAPIType type, const String16& message) + { + std::vector> arguments(1, toV8String(m_isolate, message)); + reportCall(type, arguments); + } + + void reportCall(ConsoleAPIType type, const std::vector>& arguments) + { + InspectedContext* inspectedContext = ensureInspectedContext(); + if (!inspectedContext) + return; + V8DebuggerImpl* debugger = inspectedContext->debugger(); + std::unique_ptr message = V8ConsoleMessage::createForConsoleAPI(debugger->client()->currentTimeMS(), type, arguments, debugger->captureStackTrace(false), inspectedContext); + debugger->ensureConsoleMessageStorage(inspectedContext->contextGroupId())->addMessage(std::move(message)); + } + + void reportDeprecatedCall(const char* id, const String16& message) { if (checkAndSetPrivateFlagOnConsole(id, false)) return; - if (V8DebuggerClient* debuggerClient = ensureDebuggerClient()) - debuggerClient->reportMessageToConsole(m_context, LogMessageType, WarningMessageLevel, message, nullptr, 0 /* skipArgumentsCount */); + std::vector> arguments(1, toV8String(m_isolate, message)); + reportCall(ConsoleAPIType::kWarning, arguments); } bool firstArgToBoolean(bool defaultValue) @@ -250,13 +271,13 @@ void createBoundFunctionProperty(v8::Local context, v8::Local funcName = toV8StringInternalized(context->GetIsolate(), name); v8::Local func; - if (!v8::Function::New(context, callback, console).ToLocal(&func)) + if (!v8::Function::New(context, callback, console, 0, v8::ConstructorBehavior::kThrow).ToLocal(&func)) return; func->SetName(funcName); if (description) { v8::Local returnValue = toV8String(context->GetIsolate(), description); v8::Local toStringFunction; - if (v8::Function::New(context, returnDataCallback, returnValue).ToLocal(&toStringFunction)) + if (v8::Function::New(context, returnDataCallback, returnValue, 0, v8::ConstructorBehavior::kThrow).ToLocal(&toStringFunction)) func->Set(toV8StringInternalized(context->GetIsolate(), "toString"), toStringFunction); } if (!console->Set(context, funcName, func).FromMaybe(false)) @@ -267,67 +288,67 @@ void createBoundFunctionProperty(v8::Local context, v8::Local& info) { - ConsoleHelper(info).addMessage(LogMessageType, DebugMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kDebug); } void V8Console::errorCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(LogMessageType, ErrorMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kError); } void V8Console::infoCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(LogMessageType, InfoMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kInfo); } void V8Console::logCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(LogMessageType, LogMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kLog); } void V8Console::warnCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(LogMessageType, WarningMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kWarning); } void V8Console::dirCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(DirMessageType, LogMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kDir); } void V8Console::dirxmlCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(DirXMLMessageType, LogMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kDirXML); } void V8Console::tableCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(TableMessageType, LogMessageLevel, String16(), 0); + ConsoleHelper(info).reportCall(ConsoleAPIType::kTable); } void V8Console::traceCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(TraceMessageType, LogMessageLevel, String16("console.trace"), 0); + ConsoleHelper(info).reportCallWithDefaultArgument(ConsoleAPIType::kTrace, String16("console.trace")); } void V8Console::groupCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(StartGroupMessageType, LogMessageLevel, String16("console.group"), 0); + ConsoleHelper(info).reportCallWithDefaultArgument(ConsoleAPIType::kStartGroup, String16("console.group")); } void V8Console::groupCollapsedCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(StartGroupCollapsedMessageType, LogMessageLevel, String16("console.groupCollapsed"), 0); + ConsoleHelper(info).reportCallWithDefaultArgument(ConsoleAPIType::kStartGroupCollapsed, String16("console.groupCollapsed")); } void V8Console::groupEndCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(EndGroupMessageType, LogMessageLevel, String16("console.groupEnd"), 0); + ConsoleHelper(info).reportCallWithDefaultArgument(ConsoleAPIType::kEndGroup, String16("console.groupEnd")); } void V8Console::clearCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addMessage(ClearMessageType, LogMessageLevel, String16("console.clear"), 0); + ConsoleHelper(info).reportCallWithDefaultArgument(ConsoleAPIType::kClear, String16("console.clear")); } void V8Console::countCallback(const v8::FunctionCallbackInfo& info) @@ -337,9 +358,9 @@ void V8Console::countCallback(const v8::FunctionCallbackInfo& info) String16 title = helper.firstArgToString(String16()); String16 identifier; if (title.isEmpty()) { - std::unique_ptr stackTrace = V8StackTraceImpl::capture(nullptr, 1); + std::unique_ptr stackTrace = V8StackTraceImpl::capture(nullptr, 0, 1); if (stackTrace) - identifier = stackTrace->topSourceURL() + ":" + String16::number(stackTrace->topLineNumber()); + identifier = stackTrace->topSourceURL() + ":" + String16::fromInteger(stackTrace->topLineNumber()); } else { identifier = title + "@"; } @@ -349,7 +370,7 @@ void V8Console::countCallback(const v8::FunctionCallbackInfo& info) return; int64_t count = helper.getIntFromMap(countMap, identifier, 0) + 1; helper.setIntOnMap(countMap, identifier, count); - helper.addMessage(CountMessageType, DebugMessageLevel, title + ": " + String16::number(count)); + helper.reportCallWithArgument(ConsoleAPIType::kCount, title + ": " + String16::fromInteger(count)); } void V8Console::assertCallback(const v8::FunctionCallbackInfo& info) @@ -357,14 +378,21 @@ void V8Console::assertCallback(const v8::FunctionCallbackInfo& info) ConsoleHelper helper(info); if (helper.firstArgToBoolean(false)) return; - helper.addMessage(AssertMessageType, ErrorMessageLevel, String16("console.assert"), 1); + + std::vector> arguments; + for (int i = 1; i < info.Length(); ++i) + arguments.push_back(info[i]); + if (info.Length() < 2) + arguments.push_back(toV8String(info.GetIsolate(), String16("console.assert"))); + helper.reportCall(ConsoleAPIType::kAssert, arguments); + if (V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent()) debuggerAgent->breakProgramOnException(protocol::Debugger::Paused::ReasonEnum::Assert, nullptr); } void V8Console::markTimelineCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addDeprecationMessage("V8Console#markTimelineDeprecated", "'console.markTimeline' is deprecated. Please use 'console.timeStamp' instead."); + ConsoleHelper(info).reportDeprecatedCall("V8Console#markTimelineDeprecated", "'console.markTimeline' is deprecated. Please use 'console.timeStamp' instead."); timeStampCallback(info); } @@ -412,19 +440,19 @@ static void timeEndFunction(const v8::FunctionCallbackInfo& info, boo return; double elapsed = client->currentTimeMS() - helper.getDoubleFromMap(timeMap, protocolTitle, 0.0); String16 message = protocolTitle + ": " + String16::fromDoubleFixedPrecision(elapsed, 3) + "ms"; - helper.addMessage(TimeEndMessageType, DebugMessageLevel, message); + helper.reportCallWithArgument(ConsoleAPIType::kTimeEnd, message); } } void V8Console::timelineCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addDeprecationMessage("V8Console#timeline", "'console.timeline' is deprecated. Please use 'console.time' instead."); + ConsoleHelper(info).reportDeprecatedCall("V8Console#timeline", "'console.timeline' is deprecated. Please use 'console.time' instead."); timeFunction(info, true); } void V8Console::timelineEndCallback(const v8::FunctionCallbackInfo& info) { - ConsoleHelper(info).addDeprecationMessage("V8Console#timelineEnd", "'console.timelineEnd' is deprecated. Please use 'console.timeEnd' instead."); + ConsoleHelper(info).reportDeprecatedCall("V8Console#timelineEnd", "'console.timelineEnd' is deprecated. Please use 'console.timeEnd' instead."); timeEndFunction(info, true); } @@ -507,7 +535,7 @@ static void setFunctionBreakpoint(ConsoleHelper& helper, v8::Local V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent(); if (!debuggerAgent) return; - String16 scriptId = String16::number(function->ScriptId()); + String16 scriptId = String16::fromInteger(function->ScriptId()); int lineNumber = function->GetScriptLineNumber(); int columnNumber = function->GetScriptColumnNumber(); if (lineNumber == v8::Function::kLineOffsetNotFound || columnNumber == v8::Function::kLineOffsetNotFound) @@ -661,7 +689,7 @@ v8::Local V8Console::createConsole(InspectedContext* inspectedContex DCHECK(success); if (hasMemoryAttribute) - console->SetAccessorProperty(toV8StringInternalized(isolate, "memory"), v8::Function::New(isolate, V8Console::memoryGetterCallback, console), v8::Function::New(isolate, V8Console::memorySetterCallback), static_cast(v8::None), v8::DEFAULT); + console->SetAccessorProperty(toV8StringInternalized(isolate, "memory"), v8::Function::New(context, V8Console::memoryGetterCallback, console, 0, v8::ConstructorBehavior::kThrow).ToLocalChecked(), v8::Function::New(context, V8Console::memorySetterCallback, v8::Local(), 0, v8::ConstructorBehavior::kThrow).ToLocalChecked(), static_cast(v8::None), v8::DEFAULT); console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::External::New(isolate, inspectedContext)); return console; diff --git a/deps/v8_inspector/platform/v8_inspector/V8Console.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Console.h similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/V8Console.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Console.h diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleAgentImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleAgentImpl.cpp new file mode 100644 index 00000000000000..ab4017532f4bd8 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleAgentImpl.cpp @@ -0,0 +1,88 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "platform/v8_inspector/V8ConsoleAgentImpl.h" + +#include "platform/v8_inspector/V8ConsoleMessage.h" +#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8InspectorSessionImpl.h" +#include "platform/v8_inspector/V8StackTraceImpl.h" + +namespace blink { + +namespace ConsoleAgentState { +static const char consoleEnabled[] = "consoleEnabled"; +} + +V8ConsoleAgentImpl::V8ConsoleAgentImpl(V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state) + : m_session(session) + , m_state(state) + , m_frontend(frontendChannel) + , m_enabled(false) +{ +} + +V8ConsoleAgentImpl::~V8ConsoleAgentImpl() +{ +} + +void V8ConsoleAgentImpl::enable(ErrorString* errorString) +{ + if (m_enabled) + return; + m_state->setBoolean(ConsoleAgentState::consoleEnabled, true); + m_enabled = true; + m_session->debugger()->enableStackCapturingIfNeeded(); + reportAllMessages(); +} + +void V8ConsoleAgentImpl::disable(ErrorString* errorString) +{ + if (!m_enabled) + return; + m_session->debugger()->disableStackCapturingIfNeeded(); + m_state->setBoolean(ConsoleAgentState::consoleEnabled, false); + m_enabled = false; +} + +void V8ConsoleAgentImpl::clearMessages(ErrorString* errorString) +{ +} + +void V8ConsoleAgentImpl::restore() +{ + if (!m_state->booleanProperty(ConsoleAgentState::consoleEnabled, false)) + return; + ErrorString ignored; + enable(&ignored); +} + +void V8ConsoleAgentImpl::messageAdded(V8ConsoleMessage* message) +{ + if (m_enabled) + reportMessage(message, true); +} + +bool V8ConsoleAgentImpl::enabled() +{ + return m_enabled; +} + +void V8ConsoleAgentImpl::reportAllMessages() +{ + V8ConsoleMessageStorage* storage = m_session->debugger()->ensureConsoleMessageStorage(m_session->contextGroupId()); + for (const auto& message : storage->messages()) { + if (message->origin() == V8MessageOrigin::kConsole) + reportMessage(message.get(), false); + } +} + +void V8ConsoleAgentImpl::reportMessage(V8ConsoleMessage* message, bool generatePreview) +{ + DCHECK(message->origin() == V8MessageOrigin::kConsole); + message->reportToFrontend(&m_frontend); + m_frontend.flush(); +} + +} // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleAgentImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleAgentImpl.h new file mode 100644 index 00000000000000..bc897ac352e289 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleAgentImpl.h @@ -0,0 +1,45 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8ConsoleAgentImpl_h +#define V8ConsoleAgentImpl_h + +#include "platform/inspector_protocol/Allocator.h" +#include "platform/inspector_protocol/String16.h" +#include "platform/v8_inspector/protocol/Console.h" + +namespace blink { + +class V8ConsoleMessage; +class V8InspectorSessionImpl; + +class V8ConsoleAgentImpl : public protocol::Console::Backend { + PROTOCOL_DISALLOW_COPY(V8ConsoleAgentImpl); +public: + V8ConsoleAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*, protocol::DictionaryValue* state); + ~V8ConsoleAgentImpl() override; + + void enable(ErrorString*) override; + void disable(ErrorString*) override; + void clearMessages(ErrorString*) override; + + void restore(); + void messageAdded(V8ConsoleMessage*); + void reset(); + bool enabled(); + +private: + void reportAllMessages(); + void reportMessage(V8ConsoleMessage*, bool generatePreview); + + V8InspectorSessionImpl* m_session; + protocol::DictionaryValue* m_state; + protocol::Console::Frontend m_frontend; + bool m_enabled; +}; + +} // namespace blink + + +#endif // !defined(V8ConsoleAgentImpl_h) diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleMessage.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleMessage.cpp new file mode 100644 index 00000000000000..42fe95bdfcd890 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleMessage.cpp @@ -0,0 +1,440 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "platform/v8_inspector/V8ConsoleMessage.h" + +#include "platform/v8_inspector/InspectedContext.h" +#include "platform/v8_inspector/V8ConsoleAgentImpl.h" +#include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8InspectorSessionImpl.h" +#include "platform/v8_inspector/V8RuntimeAgentImpl.h" +#include "platform/v8_inspector/V8StackTraceImpl.h" +#include "platform/v8_inspector/V8StringUtil.h" +#include "platform/v8_inspector/public/V8DebuggerClient.h" + +namespace blink { + +namespace { + +String16 consoleAPITypeValue(ConsoleAPIType type) +{ + switch (type) { + case ConsoleAPIType::kLog: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Log; + case ConsoleAPIType::kDebug: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Debug; + case ConsoleAPIType::kInfo: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Info; + case ConsoleAPIType::kError: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Error; + case ConsoleAPIType::kWarning: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Warning; + case ConsoleAPIType::kClear: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Clear; + case ConsoleAPIType::kDir: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Dir; + case ConsoleAPIType::kDirXML: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Dirxml; + case ConsoleAPIType::kTable: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Table; + case ConsoleAPIType::kTrace: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Trace; + case ConsoleAPIType::kStartGroup: return protocol::Runtime::ConsoleAPICalled::TypeEnum::StartGroup; + case ConsoleAPIType::kStartGroupCollapsed: return protocol::Runtime::ConsoleAPICalled::TypeEnum::StartGroupCollapsed; + case ConsoleAPIType::kEndGroup: return protocol::Runtime::ConsoleAPICalled::TypeEnum::EndGroup; + case ConsoleAPIType::kAssert: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Assert; + case ConsoleAPIType::kTimeEnd: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Debug; + case ConsoleAPIType::kCount: return protocol::Runtime::ConsoleAPICalled::TypeEnum::Debug; + } + return protocol::Runtime::ConsoleAPICalled::TypeEnum::Log; +} + +const unsigned maxConsoleMessageCount = 1000; +const unsigned maxArrayItemsLimit = 10000; +const unsigned maxStackDepthLimit = 32; + +class V8ValueStringBuilder { +public: + static String16 toString(v8::Local value, v8::Isolate* isolate) + { + V8ValueStringBuilder builder(isolate); + if (!builder.append(value)) + return String16(); + return builder.toString(); + } + +private: + enum { + IgnoreNull = 1 << 0, + IgnoreUndefined = 1 << 1, + }; + + V8ValueStringBuilder(v8::Isolate* isolate) + : m_arrayLimit(maxArrayItemsLimit) + , m_isolate(isolate) + , m_tryCatch(isolate) + { + } + + bool append(v8::Local value, unsigned ignoreOptions = 0) + { + if (value.IsEmpty()) + return true; + if ((ignoreOptions & IgnoreNull) && value->IsNull()) + return true; + if ((ignoreOptions & IgnoreUndefined) && value->IsUndefined()) + return true; + if (value->IsString()) + return append(v8::Local::Cast(value)); + if (value->IsStringObject()) + return append(v8::Local::Cast(value)->ValueOf()); + if (value->IsSymbol()) + return append(v8::Local::Cast(value)); + if (value->IsSymbolObject()) + return append(v8::Local::Cast(value)->ValueOf()); + if (value->IsNumberObject()) { + m_builder.appendNumber(v8::Local::Cast(value)->ValueOf()); + return true; + } + if (value->IsBooleanObject()) { + m_builder.append(v8::Local::Cast(value)->ValueOf() ? "true" : "false"); + return true; + } + if (value->IsArray()) + return append(v8::Local::Cast(value)); + if (value->IsProxy()) { + m_builder.append("[object Proxy]"); + return true; + } + if (value->IsObject() + && !value->IsDate() + && !value->IsFunction() + && !value->IsNativeError() + && !value->IsRegExp()) { + v8::Local object = v8::Local::Cast(value); + v8::Local stringValue; + if (object->ObjectProtoToString(m_isolate->GetCurrentContext()).ToLocal(&stringValue)) + return append(stringValue); + } + v8::Local stringValue; + if (!value->ToString(m_isolate->GetCurrentContext()).ToLocal(&stringValue)) + return false; + return append(stringValue); + } + + bool append(v8::Local array) + { + for (const auto& it : m_visitedArrays) { + if (it == array) + return true; + } + uint32_t length = array->Length(); + if (length > m_arrayLimit) + return false; + if (m_visitedArrays.size() > maxStackDepthLimit) + return false; + + bool result = true; + m_arrayLimit -= length; + m_visitedArrays.push_back(array); + for (uint32_t i = 0; i < length; ++i) { + if (i) + m_builder.append(','); + if (!append(array->Get(i), IgnoreNull | IgnoreUndefined)) { + result = false; + break; + } + } + m_visitedArrays.pop_back(); + return result; + } + + bool append(v8::Local symbol) + { + m_builder.append("Symbol("); + bool result = append(symbol->Name(), IgnoreUndefined); + m_builder.append(')'); + return result; + } + + bool append(v8::Local string) + { + if (m_tryCatch.HasCaught()) + return false; + if (!string.IsEmpty()) + m_builder.append(toProtocolString(string)); + return true; + } + + String16 toString() + { + if (m_tryCatch.HasCaught()) + return String16(); + return m_builder.toString(); + } + + uint32_t m_arrayLimit; + v8::Isolate* m_isolate; + String16Builder m_builder; + std::vector> m_visitedArrays; + v8::TryCatch m_tryCatch; +}; + +} // namespace + +V8ConsoleMessage::V8ConsoleMessage(V8MessageOrigin origin, double timestamp, const String16& message) + : m_origin(origin) + , m_timestamp(timestamp) + , m_message(message) + , m_lineNumber(0) + , m_columnNumber(0) + , m_scriptId(0) + , m_contextId(0) + , m_type(ConsoleAPIType::kLog) + , m_exceptionId(0) + , m_revokedExceptionId(0) +{ +} + +V8ConsoleMessage::~V8ConsoleMessage() +{ +} + +void V8ConsoleMessage::setLocation(const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr stackTrace, int scriptId) +{ + m_url = url; + m_lineNumber = lineNumber; + m_columnNumber = columnNumber; + m_stackTrace = std::move(stackTrace); + m_scriptId = scriptId; +} + +void V8ConsoleMessage::reportToFrontend(protocol::Console::Frontend* frontend) const +{ + DCHECK(m_origin == V8MessageOrigin::kConsole); + std::unique_ptr result = + protocol::Console::ConsoleMessage::create() + .setSource(protocol::Console::ConsoleMessage::SourceEnum::ConsoleApi) + .setLevel(protocol::Console::ConsoleMessage::LevelEnum::Log) + .setText(m_message) + .build(); + result->setLine(static_cast(m_lineNumber)); + result->setColumn(static_cast(m_columnNumber)); + result->setUrl(m_url); + frontend->messageAdded(std::move(result)); +} + +std::unique_ptr> V8ConsoleMessage::wrapArguments(V8InspectorSessionImpl* session, bool generatePreview) const +{ + if (!m_arguments.size() || !m_contextId) + return nullptr; + InspectedContext* inspectedContext = session->debugger()->getContext(session->contextGroupId(), m_contextId); + if (!inspectedContext) + return nullptr; + + v8::Isolate* isolate = inspectedContext->isolate(); + v8::HandleScope handles(isolate); + v8::Local context = inspectedContext->context(); + + std::unique_ptr> args = protocol::Array::create(); + if (m_type == ConsoleAPIType::kTable && generatePreview) { + v8::Local table = m_arguments[0]->Get(isolate); + v8::Local columns = m_arguments.size() > 1 ? m_arguments[1]->Get(isolate) : v8::Local(); + std::unique_ptr wrapped = session->wrapTable(context, table, columns); + if (wrapped) + args->addItem(std::move(wrapped)); + else + args = nullptr; + } else { + for (size_t i = 0; i < m_arguments.size(); ++i) { + std::unique_ptr wrapped = session->wrapObject(context, m_arguments[i]->Get(isolate), "console", generatePreview); + if (!wrapped) { + args = nullptr; + break; + } + args->addItem(std::move(wrapped)); + } + } + return args; +} + +void V8ConsoleMessage::reportToFrontend(protocol::Runtime::Frontend* frontend, V8InspectorSessionImpl* session, bool generatePreview) const +{ + if (m_origin == V8MessageOrigin::kException) { + // TODO(dgozman): unify with InjectedScript::createExceptionDetails. + std::unique_ptr details = protocol::Runtime::ExceptionDetails::create() + .setText(m_message) + .setLineNumber(m_lineNumber ? m_lineNumber - 1 : 0) + .setColumnNumber(m_columnNumber ? m_columnNumber - 1 : 0) + .setScriptId(m_scriptId ? String16::fromInteger(m_scriptId) : String16()) + .build(); + if (!m_url.isEmpty()) + details->setUrl(m_url); + if (m_stackTrace) + details->setStackTrace(m_stackTrace->buildInspectorObject()); + + std::unique_ptr exception = wrapException(session, generatePreview); + + if (exception) + frontend->exceptionThrown(m_exceptionId, m_timestamp, std::move(details), std::move(exception), m_contextId); + else + frontend->exceptionThrown(m_exceptionId, m_timestamp, std::move(details)); + return; + } + if (m_origin == V8MessageOrigin::kRevokedException) { + frontend->exceptionRevoked(m_message, m_revokedExceptionId); + return; + } + if (m_origin == V8MessageOrigin::kConsole) { + std::unique_ptr> arguments = wrapArguments(session, generatePreview); + if (!arguments) { + arguments = protocol::Array::create(); + if (!m_message.isEmpty()) { + std::unique_ptr messageArg = protocol::Runtime::RemoteObject::create().setType(protocol::Runtime::RemoteObject::TypeEnum::String).build(); + messageArg->setValue(protocol::StringValue::create(m_message)); + arguments->addItem(std::move(messageArg)); + } + } + frontend->consoleAPICalled(consoleAPITypeValue(m_type), std::move(arguments), m_contextId, m_timestamp, m_stackTrace ? m_stackTrace->buildInspectorObject() : nullptr); + return; + } + NOTREACHED(); +} + +std::unique_ptr V8ConsoleMessage::wrapException(V8InspectorSessionImpl* session, bool generatePreview) const +{ + if (!m_arguments.size() || !m_contextId) + return nullptr; + DCHECK_EQ(1u, m_arguments.size()); + InspectedContext* inspectedContext = session->debugger()->getContext(session->contextGroupId(), m_contextId); + if (!inspectedContext) + return nullptr; + + v8::Isolate* isolate = inspectedContext->isolate(); + v8::HandleScope handles(isolate); + // TODO(dgozman): should we use different object group? + return session->wrapObject(inspectedContext->context(), m_arguments[0]->Get(isolate), "console", generatePreview); +} + +V8MessageOrigin V8ConsoleMessage::origin() const +{ + return m_origin; +} + +ConsoleAPIType V8ConsoleMessage::type() const +{ + return m_type; +} + +// static +std::unique_ptr V8ConsoleMessage::createForConsoleAPI(double timestamp, ConsoleAPIType type, const std::vector>& arguments, std::unique_ptr stackTrace, InspectedContext* context) +{ + std::unique_ptr message = wrapUnique(new V8ConsoleMessage(V8MessageOrigin::kConsole, timestamp, String16())); + if (stackTrace && !stackTrace->isEmpty()) { + message->m_url = stackTrace->topSourceURL(); + message->m_lineNumber = stackTrace->topLineNumber(); + message->m_columnNumber = stackTrace->topColumnNumber(); + } + message->m_stackTrace = std::move(stackTrace); + message->m_type = type; + message->m_contextId = context->contextId(); + for (size_t i = 0; i < arguments.size(); ++i) + message->m_arguments.push_back(wrapUnique(new v8::Global(context->isolate(), arguments.at(i)))); + if (arguments.size()) + message->m_message = V8ValueStringBuilder::toString(arguments[0], context->isolate()); + + MessageLevel level = LogMessageLevel; + if (type == ConsoleAPIType::kDebug || type == ConsoleAPIType::kCount || type == ConsoleAPIType::kTimeEnd) + level = DebugMessageLevel; + if (type == ConsoleAPIType::kError || type == ConsoleAPIType::kAssert) + level = ErrorMessageLevel; + if (type == ConsoleAPIType::kWarning) + level = WarningMessageLevel; + if (type == ConsoleAPIType::kInfo) + level = InfoMessageLevel; + context->debugger()->client()->consoleAPIMessage(context->contextGroupId(), level, message->m_message, message->m_url, message->m_lineNumber, message->m_columnNumber, message->m_stackTrace.get()); + + return message; +} + +// static +std::unique_ptr V8ConsoleMessage::createForException(double timestamp, const String16& messageText, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr stackTrace, int scriptId, v8::Isolate* isolate, int contextId, v8::Local exception, unsigned exceptionId) +{ + std::unique_ptr message = wrapUnique(new V8ConsoleMessage(V8MessageOrigin::kException, timestamp, messageText)); + message->setLocation(url, lineNumber, columnNumber, std::move(stackTrace), scriptId); + message->m_exceptionId = exceptionId; + if (contextId && !exception.IsEmpty()) { + message->m_contextId = contextId; + message->m_arguments.push_back(wrapUnique(new v8::Global(isolate, exception))); + } + return message; +} + +// static +std::unique_ptr V8ConsoleMessage::createForRevokedException(double timestamp, const String16& messageText, unsigned revokedExceptionId) +{ + std::unique_ptr message = wrapUnique(new V8ConsoleMessage(V8MessageOrigin::kRevokedException, timestamp, messageText)); + message->m_revokedExceptionId = revokedExceptionId; + return message; +} + +void V8ConsoleMessage::contextDestroyed(int contextId) +{ + if (contextId != m_contextId) + return; + m_contextId = 0; + if (m_message.isEmpty()) + m_message = ""; + Arguments empty; + m_arguments.swap(empty); +} + +// ------------------------ V8ConsoleMessageStorage ---------------------------- + +V8ConsoleMessageStorage::V8ConsoleMessageStorage(V8DebuggerImpl* debugger, int contextGroupId) + : m_debugger(debugger) + , m_contextGroupId(contextGroupId) + , m_expiredCount(0) +{ +} + +V8ConsoleMessageStorage::~V8ConsoleMessageStorage() +{ + clear(); + notifyClear(); +} + +void V8ConsoleMessageStorage::addMessage(std::unique_ptr message) +{ + if (message->type() == ConsoleAPIType::kClear) { + clear(); + notifyClear(); + } + + V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_contextGroupId); + if (session) { + if (message->origin() == V8MessageOrigin::kConsole) + session->consoleAgent()->messageAdded(message.get()); + session->runtimeAgent()->messageAdded(message.get()); + } + + DCHECK(m_messages.size() <= maxConsoleMessageCount); + if (m_messages.size() == maxConsoleMessageCount) { + ++m_expiredCount; + m_messages.pop_front(); + } + m_messages.push_back(std::move(message)); +} + +void V8ConsoleMessageStorage::clear() +{ + m_messages.clear(); + m_expiredCount = 0; + if (V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_contextGroupId)) + session->releaseObjectGroup("console"); +} + +void V8ConsoleMessageStorage::contextDestroyed(int contextId) +{ + for (size_t i = 0; i < m_messages.size(); ++i) + m_messages[i]->contextDestroyed(contextId); +} + +void V8ConsoleMessageStorage::notifyClear() +{ + if (V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_contextGroupId)) + session->client()->consoleCleared(); +} + +} // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleMessage.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleMessage.h new file mode 100644 index 00000000000000..923a84e9269080 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ConsoleMessage.h @@ -0,0 +1,110 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8ConsoleMessage_h +#define V8ConsoleMessage_h + +#include "platform/inspector_protocol/Collections.h" +#include "platform/inspector_protocol/String16.h" +#include "platform/v8_inspector/protocol/Console.h" +#include "platform/v8_inspector/protocol/Runtime.h" +#include "platform/v8_inspector/public/V8ConsoleTypes.h" +#include "platform/v8_inspector/public/V8StackTrace.h" +#include +#include + +namespace blink { + +class InspectedContext; +class V8DebuggerImpl; +class V8InspectorSessionImpl; +class V8StackTrace; + +enum class V8MessageOrigin { kConsole, kException, kRevokedException }; + +enum class ConsoleAPIType { kLog, kDebug, kInfo, kError, kWarning, kDir, kDirXML, kTable, kTrace, kStartGroup, kStartGroupCollapsed, kEndGroup, kClear, kAssert, kTimeEnd, kCount }; + +class V8ConsoleMessage { +public: + ~V8ConsoleMessage(); + + static std::unique_ptr createForConsoleAPI( + double timestamp, + ConsoleAPIType, + const std::vector>& arguments, + std::unique_ptr, + InspectedContext*); + + static std::unique_ptr createForException( + double timestamp, + const String16& message, + const String16& url, + unsigned lineNumber, + unsigned columnNumber, + std::unique_ptr, + int scriptId, + v8::Isolate*, + int contextId, + v8::Local exception, + unsigned exceptionId); + + static std::unique_ptr createForRevokedException( + double timestamp, + const String16& message, + unsigned revokedExceptionId); + + V8MessageOrigin origin() const; + void reportToFrontend(protocol::Console::Frontend*) const; + void reportToFrontend(protocol::Runtime::Frontend*, V8InspectorSessionImpl*, bool generatePreview) const; + ConsoleAPIType type() const; + void contextDestroyed(int contextId); + +private: + V8ConsoleMessage(V8MessageOrigin, double timestamp, const String16& message); + + using Arguments = std::vector>>; + std::unique_ptr> wrapArguments(V8InspectorSessionImpl*, bool generatePreview) const; + std::unique_ptr wrapException(V8InspectorSessionImpl*, bool generatePreview) const; + void setLocation(const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr, int scriptId); + + V8MessageOrigin m_origin; + double m_timestamp; + String16 m_message; + String16 m_url; + unsigned m_lineNumber; + unsigned m_columnNumber; + std::unique_ptr m_stackTrace; + int m_scriptId; + int m_contextId; + ConsoleAPIType m_type; + unsigned m_exceptionId; + unsigned m_revokedExceptionId; + Arguments m_arguments; +}; + +class V8ConsoleMessageStorage { +public: + V8ConsoleMessageStorage(V8DebuggerImpl*, int contextGroupId); + ~V8ConsoleMessageStorage(); + + int contextGroupId() { return m_contextGroupId; } + int expiredCount() { return m_expiredCount; } + const std::deque>& messages() const { return m_messages; } + + void addMessage(std::unique_ptr); + void contextDestroyed(int contextId); + void clear(); + +private: + void notifyClear(); + + V8DebuggerImpl* m_debugger; + int m_contextGroupId; + int m_expiredCount; + std::deque> m_messages; +}; + +} // namespace blink + +#endif // V8ConsoleMessage_h diff --git a/deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp similarity index 66% rename from deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp index e95d4af0f57210..2b232efc2e714b 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp @@ -19,26 +19,18 @@ #include "platform/v8_inspector/public/V8ContentSearchUtil.h" #include "platform/v8_inspector/public/V8Debugger.h" #include "platform/v8_inspector/public/V8DebuggerClient.h" -#include "platform/v8_inspector/public/V8ToProtocolValue.h" + +#include using blink::protocol::Array; using blink::protocol::Maybe; using blink::protocol::Debugger::BreakpointId; using blink::protocol::Debugger::CallFrame; -using blink::protocol::Debugger::CollectionEntry; using blink::protocol::Runtime::ExceptionDetails; -using blink::protocol::Debugger::FunctionDetails; -using blink::protocol::Debugger::GeneratorObjectDetails; using blink::protocol::Runtime::ScriptId; using blink::protocol::Runtime::StackTrace; using blink::protocol::Runtime::RemoteObject; -namespace { -static const char v8AsyncTaskEventEnqueue[] = "enqueue"; -static const char v8AsyncTaskEventWillHandle[] = "willHandle"; -static const char v8AsyncTaskEventDidHandle[] = "didHandle"; -} - namespace blink { namespace DebuggerAgentState { @@ -75,7 +67,7 @@ static String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) static String16 generateBreakpointId(const String16& scriptId, int lineNumber, int columnNumber, V8DebuggerAgentImpl::BreakpointSource source) { - return scriptId + ":" + String16::number(lineNumber) + ":" + String16::number(columnNumber) + breakpointIdSuffix(source); + return scriptId + ":" + String16::fromInteger(lineNumber) + ":" + String16::fromInteger(columnNumber) + breakpointIdSuffix(source); } static bool positionComparator(const std::pair& a, const std::pair& b) @@ -85,61 +77,6 @@ static bool positionComparator(const std::pair& a, const std::pairappend(hexDigits[number & 0xF]); - number >>= 4; - } -} - -// Hash algorithm for substrings is described in "Über die Komplexität der Multiplikation in -// eingeschränkten Branchingprogrammmodellen" by Woelfe. -// http://opendatastructures.org/versions/edition-0.1d/ods-java/node33.html#SECTION00832000000000000000 -static String16 calculateHash(const String16& str) -{ - static uint64_t prime[] = { 0x3FB75161, 0xAB1F4E4F, 0x82675BC5, 0xCD924D35, 0x81ABE279 }; - static uint64_t random[] = { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0 }; - static uint32_t randomOdd[] = { 0xB4663807, 0xCC322BF5, 0xD4F91BBD, 0xA7BEA11D, 0x8F462907 }; - - uint64_t hashes[] = { 0, 0, 0, 0, 0 }; - uint64_t zi[] = { 1, 1, 1, 1, 1 }; - - const size_t hashesSize = PROTOCOL_ARRAY_LENGTH(hashes); - - size_t current = 0; - const uint32_t* data = nullptr; - data = reinterpret_cast(str.characters16()); - for (size_t i = 0; i < str.sizeInBytes() / 4; i += 4) { - uint32_t v = data[i]; - uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; - hashes[current] = (hashes[current] + zi[current] * xi) % prime[current]; - zi[current] = (zi[current] * random[current]) % prime[current]; - current = current == hashesSize - 1 ? 0 : current + 1; - } - if (str.sizeInBytes() % 4) { - uint32_t v = 0; - for (size_t i = str.sizeInBytes() - str.sizeInBytes() % 4; i < str.sizeInBytes(); ++i) { - v <<= 8; - v |= reinterpret_cast(data)[i]; - } - uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; - hashes[current] = (hashes[current] + zi[current] * xi) % prime[current]; - zi[current] = (zi[current] * random[current]) % prime[current]; - current = current == hashesSize - 1 ? 0 : current + 1; - } - - for (size_t i = 0; i < hashesSize; ++i) - hashes[i] = (hashes[i] + zi[i] * (prime[i] - 1)) % prime[i]; - - String16Builder hash; - for (size_t i = 0; i < hashesSize; ++i) - appendUnsignedAsHex(hashes[i], &hash); - return hash.toString(); -} - static bool hasInternalError(ErrorString* errorString, bool hasError) { if (hasError) @@ -172,7 +109,6 @@ V8DebuggerAgentImpl::V8DebuggerAgentImpl(V8InspectorSessionImpl* session, protoc , m_recursionLevelForStepOut(0) , m_recursionLevelForStepFrame(0) , m_skipAllPauses(false) - , m_maxAsyncCallStackDepth(0) { clearBreakDetails(); } @@ -197,14 +133,13 @@ void V8DebuggerAgentImpl::enable() m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true); debugger().debuggerAgentEnabled(); - protocol::Vector compiledScripts; + std::vector> compiledScripts; debugger().getCompiledScripts(m_session->contextGroupId(), compiledScripts); for (size_t i = 0; i < compiledScripts.size(); i++) - didParseSource(compiledScripts[i]); + didParseSource(std::move(compiledScripts[i]), true); // FIXME(WK44513): breakpoints activated flag should be synchronized between all front-ends debugger().setBreakpointsActivated(true); - m_session->changeInstrumentationCounter(+1); } bool V8DebuggerAgentImpl::enabled() @@ -229,11 +164,10 @@ void V8DebuggerAgentImpl::disable(ErrorString*) { if (!enabled()) return; - m_session->changeInstrumentationCounter(-1); m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, protocol::DictionaryValue::create()); - m_state->setNumber(DebuggerAgentState::pauseOnExceptionsState, V8DebuggerImpl::DontPauseOnExceptions); - m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, 0); + m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, V8DebuggerImpl::DontPauseOnExceptions); + m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, 0); if (!m_pausedContext.IsEmpty()) debugger().continueProgram(); @@ -244,7 +178,7 @@ void V8DebuggerAgentImpl::disable(ErrorString*) m_scripts.clear(); m_blackboxedPositions.clear(); m_breakpointIdToDebuggerBreakpointIds.clear(); - internalSetAsyncCallStackDepth(0); + m_debugger->setAsyncCallStackDepth(this, 0); m_continueToLocationBreakpointId = String16(); clearBreakDetails(); m_scheduledDebuggerStep = NoStep; @@ -261,16 +195,6 @@ void V8DebuggerAgentImpl::disable(ErrorString*) m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); } -void V8DebuggerAgentImpl::internalSetAsyncCallStackDepth(int depth) -{ - if (depth <= 0) { - m_maxAsyncCallStackDepth = 0; - allAsyncTasksCanceled(); - } else { - m_maxAsyncCallStackDepth = depth; - } -} - void V8DebuggerAgentImpl::restore() { DCHECK(!m_enabled); @@ -283,15 +207,15 @@ void V8DebuggerAgentImpl::restore() ErrorString error; int pauseState = V8DebuggerImpl::DontPauseOnExceptions; - m_state->getNumber(DebuggerAgentState::pauseOnExceptionsState, &pauseState); + m_state->getInteger(DebuggerAgentState::pauseOnExceptionsState, &pauseState); setPauseOnExceptionsImpl(&error, pauseState); DCHECK(error.isEmpty()); m_skipAllPauses = m_state->booleanProperty(DebuggerAgentState::skipAllPauses, false); int asyncCallStackDepth = 0; - m_state->getNumber(DebuggerAgentState::asyncCallStackDepth, &asyncCallStackDepth); - internalSetAsyncCallStackDepth(asyncCallStackDepth); + m_state->getInteger(DebuggerAgentState::asyncCallStackDepth, &asyncCallStackDepth); + m_debugger->setAsyncCallStackDepth(this, asyncCallStackDepth); String16 blackboxPattern; if (m_state->getString(DebuggerAgentState::blackboxPattern, &blackboxPattern)) { @@ -317,8 +241,8 @@ static std::unique_ptr buildObjectForBreakpointCookie { std::unique_ptr breakpointObject = protocol::DictionaryValue::create(); breakpointObject->setString(DebuggerAgentState::url, url); - breakpointObject->setNumber(DebuggerAgentState::lineNumber, lineNumber); - breakpointObject->setNumber(DebuggerAgentState::columnNumber, columnNumber); + breakpointObject->setInteger(DebuggerAgentState::lineNumber, lineNumber); + breakpointObject->setInteger(DebuggerAgentState::columnNumber, columnNumber); breakpointObject->setString(DebuggerAgentState::condition, condition); breakpointObject->setBoolean(DebuggerAgentState::isRegex, isRegex); return breakpointObject; @@ -360,7 +284,7 @@ void V8DebuggerAgentImpl::setBreakpointByUrl(ErrorString* errorString, String16 condition = optionalCondition.fromMaybe(""); bool isRegex = optionalURLRegex.isJust(); - String16 breakpointId = (isRegex ? "/" + url + "/" : url) + ":" + String16::number(lineNumber) + ":" + String16::number(columnNumber); + String16 breakpointId = (isRegex ? "/" + url + "/" : url) + ":" + String16::fromInteger(lineNumber) + ":" + String16::fromInteger(columnNumber); protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); if (!breakpointsCookie) { std::unique_ptr newValue = protocol::DictionaryValue::create(); @@ -375,7 +299,7 @@ void V8DebuggerAgentImpl::setBreakpointByUrl(ErrorString* errorString, breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(url, lineNumber, columnNumber, condition, isRegex)); ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); - for (auto& script : m_scripts) { + for (const auto& script : m_scripts) { if (!matches(m_debugger, script.second->sourceURL(), url, isRegex)) continue; std::unique_ptr location = resolveBreakpoint(breakpointId, script.first, breakpoint, UserBreakpointSource); @@ -410,7 +334,7 @@ void V8DebuggerAgentImpl::setBreakpoint(ErrorString* errorString, String16 condition = optionalCondition.fromMaybe(""); String16 breakpointId = generateBreakpointId(scriptId, lineNumber, columnNumber, UserBreakpointSource); - if (m_breakpointIdToDebuggerBreakpointIds.contains(breakpointId)) { + if (m_breakpointIdToDebuggerBreakpointIds.find(breakpointId) != m_breakpointIdToDebuggerBreakpointIds.end()) { *errorString = "Breakpoint at specified location already exists."; return; } @@ -438,14 +362,14 @@ void V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId) BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterator = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); if (debuggerBreakpointIdsIterator == m_breakpointIdToDebuggerBreakpointIds.end()) return; - protocol::Vector* ids = debuggerBreakpointIdsIterator->second; - for (size_t i = 0; i < ids->size(); ++i) { - const String16& debuggerBreakpointId = ids->at(i); + const std::vector& ids = debuggerBreakpointIdsIterator->second; + for (size_t i = 0; i < ids.size(); ++i) { + const String16& debuggerBreakpointId = ids[i]; debugger().removeBreakpoint(debuggerBreakpointId); - m_serverBreakpoints.remove(debuggerBreakpointId); + m_serverBreakpoints.erase(debuggerBreakpointId); } - m_breakpointIdToDebuggerBreakpointIds.remove(breakpointId); + m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); } void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString, @@ -475,7 +399,8 @@ void V8DebuggerAgentImpl::getBacktrace(ErrorString* errorString, std::unique_ptr { if (!assertPaused(errorString)) return; - m_pausedCallFrames.swap(debugger().currentCallFrames()); + JavaScriptCallFrames frames = debugger().currentCallFrames(); + m_pausedCallFrames.swap(frames); *callFrames = currentCallFrames(errorString); if (!*callFrames) return; @@ -487,7 +412,7 @@ bool V8DebuggerAgentImpl::isCurrentCallStackEmptyOrBlackboxed() DCHECK(enabled()); JavaScriptCallFrames callFrames = debugger().currentCallFrames(); for (size_t index = 0; index < callFrames.size(); ++index) { - if (!isCallFrameWithUnknownScriptOrBlackboxed(callFrames[index])) + if (!isCallFrameWithUnknownScriptOrBlackboxed(callFrames[index].get())) return false; } return true; @@ -496,32 +421,34 @@ bool V8DebuggerAgentImpl::isCurrentCallStackEmptyOrBlackboxed() bool V8DebuggerAgentImpl::isTopPausedCallFrameBlackboxed() { DCHECK(enabled()); - return isCallFrameWithUnknownScriptOrBlackboxed(m_pausedCallFrames.size() ? m_pausedCallFrames[0] : nullptr); + JavaScriptCallFrame* frame = m_pausedCallFrames.size() ? m_pausedCallFrames[0].get() : nullptr; + return isCallFrameWithUnknownScriptOrBlackboxed(frame); } bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCallFrame* frame) { if (!frame) return true; - ScriptsMap::iterator it = m_scripts.find(String16::number(frame->sourceID())); + ScriptsMap::iterator it = m_scripts.find(String16::fromInteger(frame->sourceID())); if (it == m_scripts.end()) { // Unknown scripts are blackboxed. return true; } if (m_blackboxPattern) { - String16 scriptSourceURL = it->second->sourceURL(); + const String16& scriptSourceURL = it->second->sourceURL(); if (!scriptSourceURL.isEmpty() && m_blackboxPattern->match(scriptSourceURL) != -1) return true; } - auto itBlackboxedPositions = m_blackboxedPositions.find(String16::number(frame->sourceID())); + auto itBlackboxedPositions = m_blackboxedPositions.find(String16::fromInteger(frame->sourceID())); if (itBlackboxedPositions == m_blackboxedPositions.end()) return false; - protocol::Vector>* ranges = itBlackboxedPositions->second; - auto itRange = std::lower_bound(ranges->begin(), ranges->end(), std::make_pair(frame->line(), frame->column()), positionComparator); + const std::vector>& ranges = itBlackboxedPositions->second; + auto itRange = std::lower_bound(ranges.begin(), ranges.end(), + std::make_pair(frame->line(), frame->column()), positionComparator); // Ranges array contains positions in script where blackbox state is changed. // [(0,0) ... ranges[0]) isn't blackboxed, [ranges[0] ... ranges[1]) is blackboxed... - return std::distance(ranges->begin(), itRange) % 2; + return std::distance(ranges.begin(), itRange) % 2; } V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::shouldSkipExceptionPause(JavaScriptCallFrame* topCallFrame) @@ -566,8 +493,7 @@ std::unique_ptr V8DebuggerAgentImpl::resolveBreakp ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); if (scriptIterator == m_scripts.end()) return nullptr; - V8DebuggerScript* script = scriptIterator->second; - if (breakpoint.lineNumber < script->startLine() || script->endLine() < breakpoint.lineNumber) + if (breakpoint.lineNumber < scriptIterator->second->startLine() || scriptIterator->second->endLine() < breakpoint.lineNumber) return nullptr; int actualLineNumber; @@ -576,14 +502,10 @@ std::unique_ptr V8DebuggerAgentImpl::resolveBreakp if (debuggerBreakpointId.isEmpty()) return nullptr; - m_serverBreakpoints.set(debuggerBreakpointId, std::make_pair(breakpointId, source)); + m_serverBreakpoints[debuggerBreakpointId] = std::make_pair(breakpointId, source); CHECK(!breakpointId.isEmpty()); - if (!m_breakpointIdToDebuggerBreakpointIds.contains(breakpointId)) - m_breakpointIdToDebuggerBreakpointIds.set(breakpointId, protocol::Vector()); - - BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterator = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); - debuggerBreakpointIdsIterator->second->append(debuggerBreakpointId); + m_breakpointIdToDebuggerBreakpointIds[breakpointId].push_back(debuggerBreakpointId); return buildProtocolLocation(scriptId, actualLineNumber, actualColumnNumber); } @@ -592,9 +514,10 @@ void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String16& sc const Maybe& optionalIsRegex, std::unique_ptr>* results) { + v8::HandleScope handles(m_isolate); ScriptsMap::iterator it = m_scripts.find(scriptId); if (it != m_scripts.end()) - *results = V8ContentSearchUtil::searchInTextByLines(m_session, it->second->source(), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fromMaybe(false)); + *results = V8ContentSearchUtil::searchInTextByLines(m_session, toProtocolString(it->second->source(m_isolate)), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fromMaybe(false)); else *error = String16("No script for id: " + scriptId); } @@ -606,23 +529,25 @@ void V8DebuggerAgentImpl::setScriptSource(ErrorString* errorString, Maybe>* newCallFrames, Maybe* stackChanged, Maybe* asyncStackTrace, - Maybe* optOutCompileError) + Maybe* optOutCompileError) { if (!checkEnabled(errorString)) return; - if (!debugger().setScriptSource(scriptId, newContent, preview.fromMaybe(false), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged)) + + v8::HandleScope handles(m_isolate); + v8::Local newSource = toV8String(m_isolate, newContent); + if (!debugger().setScriptSource(scriptId, newSource, preview.fromMaybe(false), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged)) return; + ScriptsMap::iterator it = m_scripts.find(scriptId); + if (it != m_scripts.end()) + it->second->setSource(m_isolate, newSource); + std::unique_ptr> callFrames = currentCallFrames(errorString); if (!callFrames) return; *newCallFrames = std::move(callFrames); *asyncStackTrace = currentAsyncStackTrace(); - - ScriptsMap::iterator it = m_scripts.find(scriptId); - if (it == m_scripts.end()) - return; - it->second->setSource(newContent); } void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, @@ -646,7 +571,8 @@ void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, *errorString = "Internal error"; return; } - m_pausedCallFrames.swap(debugger().currentCallFrames()); + JavaScriptCallFrames frames = debugger().currentCallFrames(); + m_pausedCallFrames.swap(frames); *newCallFrames = currentCallFrames(errorString); if (!*newCallFrames) @@ -663,106 +589,8 @@ void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc *error = "No script for id: " + scriptId; return; } - *scriptSource = it->second->source(); -} - -void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const String16& functionId, std::unique_ptr* details) -{ - if (!checkEnabled(errorString)) - return; - InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contextGroupId(), functionId); - if (!scope.initialize()) - return; - if (!scope.object()->IsFunction()) { - *errorString = "Value with given id is not a function"; - return; - } - v8::Local function = scope.object().As(); - - v8::Local scopesValue; - v8::Local scopes; - if (m_debugger->functionScopes(function).ToLocal(&scopesValue) && scopesValue->IsArray()) { - scopes = scopesValue.As(); - if (!scope.injectedScript()->wrapPropertyInArray(errorString, scopes, toV8StringInternalized(m_isolate, "object"), scope.objectGroupName())) - return; - } - - std::unique_ptr functionDetails = FunctionDetails::create() - .setLocation(buildProtocolLocation(String16::number(function->ScriptId()), function->GetScriptLineNumber(), function->GetScriptColumnNumber())) - .setFunctionName(toProtocolStringWithTypeCheck(function->GetDebugName())) - .setIsGenerator(function->IsGeneratorFunction()).build(); - - if (!scopes.IsEmpty()) { - protocol::ErrorSupport errorSupport; - std::unique_ptr> scopeChain = protocol::Array::parse(toProtocolValue(scope.context(), scopes).get(), &errorSupport); - if (hasInternalError(errorString, errorSupport.hasErrors())) - return; - functionDetails->setScopeChain(std::move(scopeChain)); - } - - *details = std::move(functionDetails); -} - -void V8DebuggerAgentImpl::getGeneratorObjectDetails(ErrorString* errorString, const String16& objectId, std::unique_ptr* outDetails) -{ - if (!checkEnabled(errorString)) - return; - InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contextGroupId(), objectId); - if (!scope.initialize()) - return; - if (!scope.object()->IsObject()) { - *errorString = "Value with given id is not an Object"; - return; - } - v8::Local object = scope.object().As(); - - v8::Local detailsObject; - v8::Local detailsValue = debugger().generatorObjectDetails(object); - if (hasInternalError(errorString, !detailsValue->IsObject() || !detailsValue->ToObject(scope.context()).ToLocal(&detailsObject))) - return; - - if (!scope.injectedScript()->wrapObjectProperty(errorString, detailsObject, toV8StringInternalized(m_isolate, "function"), scope.objectGroupName())) - return; - - protocol::ErrorSupport errors; - std::unique_ptr protocolDetails = GeneratorObjectDetails::parse(toProtocolValue(scope.context(), detailsObject).get(), &errors); - if (hasInternalError(errorString, !protocolDetails)) - return; - *outDetails = std::move(protocolDetails); -} - -void V8DebuggerAgentImpl::getCollectionEntries(ErrorString* errorString, const String16& objectId, std::unique_ptr>* outEntries) -{ - if (!checkEnabled(errorString)) - return; - InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contextGroupId(), objectId); - if (!scope.initialize()) - return; - if (!scope.object()->IsObject()) { - *errorString = "Object with given id is not a collection"; - return; - } - v8::Local object = scope.object().As(); - - v8::Local entriesValue = m_debugger->collectionEntries(object); - if (hasInternalError(errorString, entriesValue.IsEmpty())) - return; - if (entriesValue->IsUndefined()) { - *errorString = "Object with given id is not a collection"; - return; - } - if (hasInternalError(errorString, !entriesValue->IsArray())) - return; - v8::Local entriesArray = entriesValue.As(); - if (!scope.injectedScript()->wrapPropertyInArray(errorString, entriesArray, toV8StringInternalized(m_isolate, "key"), scope.objectGroupName())) - return; - if (!scope.injectedScript()->wrapPropertyInArray(errorString, entriesArray, toV8StringInternalized(m_isolate, "value"), scope.objectGroupName())) - return; - protocol::ErrorSupport errors; - std::unique_ptr> entries = protocol::Array::parse(toProtocolValue(scope.context(), entriesArray).get(), &errors); - if (hasInternalError(errorString, !entries)) - return; - *outEntries = std::move(entries); + v8::HandleScope handles(m_isolate); + *scriptSource = toProtocolString(it->second->source(m_isolate)); } void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String16& breakReason, std::unique_ptr data) @@ -797,26 +625,6 @@ void V8DebuggerAgentImpl::cancelPauseOnNextStatement() debugger().setPauseOnNextStatement(false); } -bool V8DebuggerAgentImpl::v8AsyncTaskEventsEnabled() const -{ - return m_maxAsyncCallStackDepth; -} - -void V8DebuggerAgentImpl::didReceiveV8AsyncTaskEvent(v8::Local context, const String16& eventType, const String16& eventName, int id) -{ - DCHECK(m_maxAsyncCallStackDepth); - // The scopes for the ids are defined by the eventName namespaces. There are currently two namespaces: "Object." and "Promise.". - void* ptr = reinterpret_cast(id * 4 + (eventName[0] == 'P' ? 2 : 0) + 1); - if (eventType == v8AsyncTaskEventEnqueue) - asyncTaskScheduled(eventName, ptr, false); - else if (eventType == v8AsyncTaskEventWillHandle) - asyncTaskStarted(ptr); - else if (eventType == v8AsyncTaskEventDidHandle) - asyncTaskFinished(ptr); - else - NOTREACHED(); -} - void V8DebuggerAgentImpl::pause(ErrorString* errorString) { if (!checkEnabled(errorString)) @@ -846,7 +654,7 @@ void V8DebuggerAgentImpl::stepOver(ErrorString* errorString) if (!assertPaused(errorString)) return; // StepOver at function return point should fallback to StepInto. - JavaScriptCallFrame* frame = m_pausedCallFrames.size() ? m_pausedCallFrames[0] : nullptr; + JavaScriptCallFrame* frame = !m_pausedCallFrames.empty() ? m_pausedCallFrames[0].get() : nullptr; if (frame && frame->isAtReturn()) { stepInto(errorString); return; @@ -903,7 +711,7 @@ void V8DebuggerAgentImpl::setPauseOnExceptionsImpl(ErrorString* errorString, int if (debugger().getPauseOnExceptionsState() != pauseState) *errorString = "Internal error. Could not change pause on exceptions state"; else - m_state->setNumber(DebuggerAgentState::pauseOnExceptionsState, pauseState); + m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, pauseState); } void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, @@ -982,71 +790,8 @@ void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d { if (!checkEnabled(errorString)) return; - m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth); - internalSetAsyncCallStackDepth(depth); -} - -void V8DebuggerAgentImpl::asyncTaskScheduled(const String16& taskName, void* task, bool recurring) -{ - if (!m_maxAsyncCallStackDepth) - return; - v8::HandleScope scope(m_isolate); - std::unique_ptr chain = V8StackTraceImpl::capture(this, V8StackTrace::maxCallStackSizeToCapture, taskName); - if (chain) { - m_asyncTaskStacks.set(task, std::move(chain)); - if (recurring) - m_recurringTasks.add(task); - } -} - -void V8DebuggerAgentImpl::asyncTaskCanceled(void* task) -{ - if (!m_maxAsyncCallStackDepth) - return; - m_asyncTaskStacks.remove(task); - m_recurringTasks.remove(task); -} - -void V8DebuggerAgentImpl::asyncTaskStarted(void* task) -{ - // Not enabled, return. - if (!m_maxAsyncCallStackDepth) - return; - - m_currentTasks.append(task); - V8StackTraceImpl* stack = m_asyncTaskStacks.get(task); - // Needs to support following order of events: - // - asyncTaskScheduled - // <-- attached here --> - // - asyncTaskStarted - // - asyncTaskCanceled <-- canceled before finished - // <-- async stack requested here --> - // - asyncTaskFinished - m_currentStacks.append(stack ? stack->cloneImpl() : nullptr); -} - -void V8DebuggerAgentImpl::asyncTaskFinished(void* task) -{ - if (!m_maxAsyncCallStackDepth) - return; - // We could start instrumenting half way and the stack is empty. - if (!m_currentStacks.size()) - return; - - DCHECK(m_currentTasks.last() == task); - m_currentTasks.removeLast(); - - m_currentStacks.removeLast(); - if (!m_recurringTasks.contains(task)) - m_asyncTaskStacks.remove(task); -} - -void V8DebuggerAgentImpl::allAsyncTasksCanceled() -{ - m_asyncTaskStacks.clear(); - m_recurringTasks.clear(); - m_currentStacks.clear(); - m_currentTasks.clear(); + m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, depth); + m_debugger->setAsyncCallStackDepth(this, depth); } void V8DebuggerAgentImpl::setBlackboxPatterns(ErrorString* errorString, std::unique_ptr> patterns) @@ -1058,10 +803,13 @@ void V8DebuggerAgentImpl::setBlackboxPatterns(ErrorString* errorString, std::uni } String16Builder patternBuilder; - patternBuilder.append("("); - for (size_t i = 0; i < patterns->length() - 1; ++i) - patternBuilder.append(patterns->get(i) + "|"); - patternBuilder.append(patterns->get(patterns->length() - 1) + ")"); + patternBuilder.append('('); + for (size_t i = 0; i < patterns->length() - 1; ++i) { + patternBuilder.append(patterns->get(i)); + patternBuilder.append("|"); + } + patternBuilder.append(patterns->get(patterns->length() - 1)); + patternBuilder.append(')'); String16 pattern = patternBuilder.toString(); if (!setBlackboxPattern(errorString, pattern)) return; @@ -1079,30 +827,32 @@ bool V8DebuggerAgentImpl::setBlackboxPattern(ErrorString* errorString, const Str return true; } -void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String16& scriptId, std::unique_ptr> inPositions) +void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String16& scriptId, + std::unique_ptr> inPositions) { - if (!m_scripts.contains(scriptId)) { + if (m_scripts.find(scriptId) == m_scripts.end()) { *error = "No script with passed id."; return; } if (!inPositions->length()) { - m_blackboxedPositions.remove(scriptId); + m_blackboxedPositions.erase(scriptId); return; } - protocol::Vector> positions(inPositions->length()); - for (size_t i = 0; i < positions.size(); ++i) { + std::vector> positions; + positions.reserve(inPositions->length()); + for (size_t i = 0; i < inPositions->length(); ++i) { protocol::Debugger::ScriptPosition* position = inPositions->get(i); - if (position->getLine() < 0) { + if (position->getLineNumber() < 0) { *error = "Position missing 'line' or 'line' < 0."; return; } - if (position->getColumn() < 0) { + if (position->getColumnNumber() < 0) { *error = "Position missing 'column' or 'column' < 0."; return; } - positions[i] = std::make_pair(position->getLine(), position->getColumn()); + positions.push_back(std::make_pair(position->getLineNumber(), position->getColumnNumber())); } for (size_t i = 1; i < positions.size(); ++i) { @@ -1114,7 +864,7 @@ void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String16 return; } - m_blackboxedPositions.set(scriptId, positions); + m_blackboxedPositions[scriptId] = positions; } void V8DebuggerAgentImpl::willExecuteScript(int scriptId) @@ -1124,7 +874,7 @@ void V8DebuggerAgentImpl::willExecuteScript(int scriptId) if (m_scheduledDebuggerStep != StepInto) return; // Skip unknown scripts (e.g. InjectedScript). - if (!m_scripts.contains(String16::number(scriptId))) + if (m_scripts.find(String16::fromInteger(scriptId)) == m_scripts.end()) return; schedulePauseOnNextStatementIfSteppingInto(); } @@ -1172,19 +922,14 @@ std::unique_ptr> V8DebuggerAgentImpl::currentCallFrames(ErrorSt if (m_pausedContext.IsEmpty() || !m_pausedCallFrames.size()) return Array::create(); ErrorString ignored; - InjectedScript* topFrameInjectedScript = m_session->findInjectedScript(&ignored, V8Debugger::contextId(m_pausedContext.Get(m_isolate))); - if (!topFrameInjectedScript) { - // Context has been reported as removed while on pause. - return Array::create(); - } - v8::HandleScope handles(m_isolate); - v8::Local context = topFrameInjectedScript->context()->context(); - v8::Context::Scope contextScope(context); + v8::Local debuggerContext = v8::Debug::GetDebugContext(m_isolate); + v8::Context::Scope contextScope(debuggerContext); v8::Local objects = v8::Array::New(m_isolate); + for (size_t frameOrdinal = 0; frameOrdinal < m_pausedCallFrames.size(); ++frameOrdinal) { - JavaScriptCallFrame* currentCallFrame = m_pausedCallFrames[frameOrdinal]; + const std::unique_ptr& currentCallFrame = m_pausedCallFrames[frameOrdinal]; v8::Local details = currentCallFrame->details(); if (hasInternalError(errorString, details.IsEmpty())) @@ -1192,34 +937,42 @@ std::unique_ptr> V8DebuggerAgentImpl::currentCallFrames(ErrorSt int contextId = currentCallFrame->contextId(); InjectedScript* injectedScript = contextId ? m_session->findInjectedScript(&ignored, contextId) : nullptr; - if (!injectedScript) - injectedScript = topFrameInjectedScript; - String16 callFrameId = RemoteCallFrameId::serialize(injectedScript->context()->contextId(), frameOrdinal); - if (hasInternalError(errorString, !details->Set(context, toV8StringInternalized(m_isolate, "callFrameId"), toV8String(m_isolate, callFrameId)).FromMaybe(false))) + String16 callFrameId = RemoteCallFrameId::serialize(contextId, frameOrdinal); + if (hasInternalError(errorString, !details->Set(debuggerContext, toV8StringInternalized(m_isolate, "callFrameId"), toV8String(m_isolate, callFrameId)).FromMaybe(false))) return Array::create(); - v8::Local scopeChain; - if (hasInternalError(errorString, !details->Get(context, toV8StringInternalized(m_isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChain->IsArray())) - return Array::create(); - v8::Local scopeChainArray = scopeChain.As(); - if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArray, toV8StringInternalized(m_isolate, "object"), V8InspectorSession::backtraceObjectGroup)) - return Array::create(); - - if (!injectedScript->wrapObjectProperty(errorString, details, toV8StringInternalized(m_isolate, "this"), V8InspectorSession::backtraceObjectGroup)) - return Array::create(); - - if (details->Has(context, toV8StringInternalized(m_isolate, "returnValue")).FromMaybe(false)) { - if (!injectedScript->wrapObjectProperty(errorString, details, toV8StringInternalized(m_isolate, "returnValue"), V8InspectorSession::backtraceObjectGroup)) + if (injectedScript) { + v8::Local scopeChain; + if (hasInternalError(errorString, !details->Get(debuggerContext, toV8StringInternalized(m_isolate, "scopeChain")).ToLocal(&scopeChain) || !scopeChain->IsArray())) + return Array::create(); + v8::Local scopeChainArray = scopeChain.As(); + if (!injectedScript->wrapPropertyInArray(errorString, scopeChainArray, toV8StringInternalized(m_isolate, "object"), V8InspectorSession::backtraceObjectGroup)) + return Array::create(); + if (!injectedScript->wrapObjectProperty(errorString, details, toV8StringInternalized(m_isolate, "this"), V8InspectorSession::backtraceObjectGroup)) + return Array::create(); + if (details->Has(debuggerContext, toV8StringInternalized(m_isolate, "returnValue")).FromMaybe(false)) { + if (!injectedScript->wrapObjectProperty(errorString, details, toV8StringInternalized(m_isolate, "returnValue"), V8InspectorSession::backtraceObjectGroup)) + return Array::create(); + } + } else { + if (hasInternalError(errorString, !details->Set(debuggerContext, toV8StringInternalized(m_isolate, "scopeChain"), v8::Array::New(m_isolate, 0)).FromMaybe(false))) + return Array::create(); + v8::Local remoteObject = v8::Object::New(m_isolate); + if (hasInternalError(errorString, !remoteObject->Set(debuggerContext, toV8StringInternalized(m_isolate, "type"), toV8StringInternalized(m_isolate, "undefined")).FromMaybe(false))) + return Array::create(); + if (hasInternalError(errorString, !details->Set(debuggerContext, toV8StringInternalized(m_isolate, "this"), remoteObject).FromMaybe(false))) + return Array::create(); + if (hasInternalError(errorString, !details->Delete(debuggerContext, toV8StringInternalized(m_isolate, "returnValue")).FromMaybe(false))) return Array::create(); } - if (hasInternalError(errorString, !objects->Set(context, frameOrdinal, details).FromMaybe(false))) + if (hasInternalError(errorString, !objects->Set(debuggerContext, frameOrdinal, details).FromMaybe(false))) return Array::create(); } protocol::ErrorSupport errorSupport; - std::unique_ptr> callFrames = Array::parse(toProtocolValue(context, objects).get(), &errorSupport); + std::unique_ptr> callFrames = Array::parse(toProtocolValue(debuggerContext, objects).get(), &errorSupport); if (hasInternalError(errorString, !callFrames)) return Array::create(); return callFrames; @@ -1227,60 +980,50 @@ std::unique_ptr> V8DebuggerAgentImpl::currentCallFrames(ErrorSt std::unique_ptr V8DebuggerAgentImpl::currentAsyncStackTrace() { - if (m_pausedContext.IsEmpty() || !m_maxAsyncCallStackDepth || !m_currentStacks.size() || !m_currentStacks.last()) - return nullptr; - - return m_currentStacks.last()->buildInspectorObjectForTail(this); -} - -V8StackTraceImpl* V8DebuggerAgentImpl::currentAsyncCallChain() -{ - if (!m_currentStacks.size()) + if (m_pausedContext.IsEmpty()) return nullptr; - return m_currentStacks.last(); + V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); + return stackTrace ? stackTrace->buildInspectorObjectForTail(m_debugger) : nullptr; } -void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScript) +void V8DebuggerAgentImpl::didParseSource(std::unique_ptr script, bool success) { - V8DebuggerScript script = parsedScript.script; - + v8::HandleScope handles(m_isolate); + String16 scriptSource = toProtocolString(script->source(m_isolate)); bool isDeprecatedSourceURL = false; - if (!parsedScript.success) - script.setSourceURL(V8ContentSearchUtil::findSourceURL(script.source(), false, &isDeprecatedSourceURL)); - else if (script.hasSourceURL()) - V8ContentSearchUtil::findSourceURL(script.source(), false, &isDeprecatedSourceURL); + if (!success) + script->setSourceURL(V8ContentSearchUtil::findSourceURL(scriptSource, false, &isDeprecatedSourceURL)); + else if (script->hasSourceURL()) + V8ContentSearchUtil::findSourceURL(scriptSource, false, &isDeprecatedSourceURL); bool isDeprecatedSourceMappingURL = false; - if (!parsedScript.success) - script.setSourceMappingURL(V8ContentSearchUtil::findSourceMapURL(script.source(), false, &isDeprecatedSourceMappingURL)); - else if (!script.sourceMappingURL().isEmpty()) - V8ContentSearchUtil::findSourceMapURL(script.source(), false, &isDeprecatedSourceMappingURL); - - script.setHash(calculateHash(script.source())); - - int executionContextId = script.executionContextId(); - bool isContentScript = script.isContentScript(); - bool isInternalScript = script.isInternalScript(); - bool isLiveEdit = script.isLiveEdit(); - bool hasSourceURL = script.hasSourceURL(); - String16 scriptURL = script.sourceURL(); - String16 sourceMapURL = script.sourceMappingURL(); + if (!success) + script->setSourceMappingURL(V8ContentSearchUtil::findSourceMapURL(scriptSource, false, &isDeprecatedSourceMappingURL)); + else if (!script->sourceMappingURL().isEmpty()) + V8ContentSearchUtil::findSourceMapURL(scriptSource, false, &isDeprecatedSourceMappingURL); + + bool isContentScript = script->isContentScript(); + bool isInternalScript = script->isInternalScript(); + bool isLiveEdit = script->isLiveEdit(); + bool hasSourceURL = script->hasSourceURL(); + String16 scriptId = script->scriptId(); + String16 scriptURL = script->sourceURL(); bool deprecatedCommentWasUsed = isDeprecatedSourceURL || isDeprecatedSourceMappingURL; - const Maybe& sourceMapURLParam = sourceMapURL; + const Maybe& sourceMapURLParam = script->sourceMappingURL(); const bool* isContentScriptParam = isContentScript ? &isContentScript : nullptr; const bool* isInternalScriptParam = isInternalScript ? &isInternalScript : nullptr; const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; const bool* deprecatedCommentWasUsedParam = deprecatedCommentWasUsed ? &deprecatedCommentWasUsed : nullptr; - if (parsedScript.success) - m_frontend.scriptParsed(parsedScript.scriptId, scriptURL, script.startLine(), script.startColumn(), script.endLine(), script.endColumn(), executionContextId, script.hash(), isContentScriptParam, isInternalScriptParam, isLiveEditParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); + if (success) + m_frontend.scriptParsed(scriptId, scriptURL, script->startLine(), script->startColumn(), script->endLine(), script->endColumn(), script->executionContextId(), script->hash(), isContentScriptParam, isInternalScriptParam, isLiveEditParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); else - m_frontend.scriptFailedToParse(parsedScript.scriptId, scriptURL, script.startLine(), script.startColumn(), script.endLine(), script.endColumn(), executionContextId, script.hash(), isContentScriptParam, isInternalScriptParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); + m_frontend.scriptFailedToParse(scriptId, scriptURL, script->startLine(), script->startColumn(), script->endLine(), script->endColumn(), script->executionContextId(), script->hash(), isContentScriptParam, isInternalScriptParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); - m_scripts.set(parsedScript.scriptId, script); + m_scripts[scriptId] = std::move(script); - if (scriptURL.isEmpty() || !parsedScript.success) + if (scriptURL.isEmpty() || !success) return; protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); @@ -1297,24 +1040,24 @@ void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr if (!matches(m_debugger, scriptURL, url, isRegex)) continue; ScriptBreakpoint breakpoint; - breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint.lineNumber); - breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoint.columnNumber); + breakpointObject->getInteger(DebuggerAgentState::lineNumber, &breakpoint.lineNumber); + breakpointObject->getInteger(DebuggerAgentState::columnNumber, &breakpoint.columnNumber); breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.condition); - std::unique_ptr location = resolveBreakpoint(cookie.first, parsedScript.scriptId, breakpoint, UserBreakpointSource); + std::unique_ptr location = resolveBreakpoint(cookie.first, scriptId, breakpoint, UserBreakpointSource); if (location) m_frontend.breakpointResolved(cookie.first, std::move(location)); } } -V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local context, v8::Local exception, const protocol::Vector& hitBreakpoints, bool isPromiseRejection) +V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local context, v8::Local exception, const std::vector& hitBreakpoints, bool isPromiseRejection) { JavaScriptCallFrames callFrames = debugger().currentCallFrames(1); - JavaScriptCallFrame* topCallFrame = callFrames.size() > 0 ? callFrames[0] : nullptr; + JavaScriptCallFrame* topCallFrame = !callFrames.empty() ? callFrames.begin()->get() : nullptr; V8DebuggerAgentImpl::SkipPauseRequest result; if (m_skipAllPauses) result = RequestContinue; - else if (!hitBreakpoints.isEmpty()) + else if (!hitBreakpoints.empty()) result = RequestNoSkip; // Don't skip explicit breakpoints even if set in frameworks. else if (!exception.IsEmpty()) result = shouldSkipExceptionPause(topCallFrame); @@ -1331,13 +1074,14 @@ V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::LocalfindInjectedScript(&ignored, V8Debugger::contextId(context)); + InjectedScript* injectedScript = m_session->findInjectedScript(&ignored, V8DebuggerImpl::contextId(context)); if (injectedScript) { m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::ReasonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; ErrorString errorString; @@ -1352,10 +1096,10 @@ V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Localsecond->first; + const String16& localId = breakpointIterator->second.first; hitBreakpointIds->addItem(localId); - BreakpointSource source = breakpointIterator->second->second; + BreakpointSource source = breakpointIterator->second.second; if (m_breakReason == protocol::Debugger::Paused::ReasonEnum::Other && source == DebugCommandBreakpointSource) m_breakReason = protocol::Debugger::Paused::ReasonEnum::DebugCommand; } @@ -1440,7 +1184,6 @@ void V8DebuggerAgentImpl::reset() m_scripts.clear(); m_blackboxedPositions.clear(); m_breakpointIdToDebuggerBreakpointIds.clear(); - allAsyncTasksCanceled(); } } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h similarity index 82% rename from deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h index ab04bb50a43a11..b6aea619e10318 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h @@ -10,6 +10,8 @@ #include "platform/v8_inspector/V8DebuggerImpl.h" #include "platform/v8_inspector/protocol/Debugger.h" +#include + namespace blink { class JavaScriptCallFrame; @@ -84,21 +86,12 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { Maybe>* optOutCallFrames, Maybe* optOutStackChanged, Maybe* optOutAsyncStackTrace, - Maybe* optOutCompileError) override; + Maybe* optOutCompileError) override; void restartFrame(ErrorString*, const String16& callFrameId, std::unique_ptr>* newCallFrames, Maybe* asyncStackTrace) override; void getScriptSource(ErrorString*, const String16& scriptId, String16* scriptSource) override; - void getFunctionDetails(ErrorString*, - const String16& functionId, - std::unique_ptr*) override; - void getGeneratorObjectDetails(ErrorString*, - const String16& objectId, - std::unique_ptr*) override; - void getCollectionEntries(ErrorString*, - const String16& objectId, - std::unique_ptr>*) override; void pause(ErrorString*) override; void resume(ErrorString*) override; void stepOver(ErrorString*) override; @@ -138,27 +131,16 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { void breakProgram(const String16& breakReason, std::unique_ptr data); void breakProgramOnException(const String16& breakReason, std::unique_ptr data); - // Async call stacks implementation. - void asyncTaskScheduled(const String16& taskName, void* task, bool recurring); - void asyncTaskCanceled(void* task); - void asyncTaskStarted(void* task); - void asyncTaskFinished(void* task); - void allAsyncTasksCanceled(); - void reset(); // Interface for V8DebuggerImpl - SkipPauseRequest didPause(v8::Local, v8::Local exception, const protocol::Vector& hitBreakpoints, bool isPromiseRejection); + SkipPauseRequest didPause(v8::Local, v8::Local exception, const std::vector& hitBreakpoints, bool isPromiseRejection); void didContinue(); - void didParseSource(const V8DebuggerParsedScript&); - bool v8AsyncTaskEventsEnabled() const; - void didReceiveV8AsyncTaskEvent(v8::Local, const String16& eventType, const String16& eventName, int id); + void didParseSource(std::unique_ptr, bool success); void willExecuteScript(int scriptId); void didExecuteScript(); v8::Isolate* isolate() { return m_isolate; } - int maxAsyncCallChainDepth() { return m_maxAsyncCallStackDepth; } - V8StackTraceImpl* currentAsyncCallChain(); private: bool checkEnabled(ErrorString*); @@ -190,8 +172,8 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { bool setBlackboxPattern(ErrorString*, const String16& pattern); - using ScriptsMap = protocol::HashMap; - using BreakpointIdToDebuggerBreakpointIdsMap = protocol::HashMap>; + using ScriptsMap = protocol::HashMap>; + using BreakpointIdToDebuggerBreakpointIdsMap = protocol::HashMap>; using DebugServerBreakpointToBreakpointIdAndSourceMap = protocol::HashMap>; using MuteBreakpoins = protocol::HashMap>; @@ -227,14 +209,8 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { int m_recursionLevelForStepFrame; bool m_skipAllPauses; - using AsyncTaskToStackTrace = protocol::HashMap>; - AsyncTaskToStackTrace m_asyncTaskStacks; - protocol::HashSet m_recurringTasks; - int m_maxAsyncCallStackDepth; - protocol::Vector m_currentTasks; - protocol::Vector> m_currentStacks; std::unique_ptr m_blackboxPattern; - protocol::HashMap>> m_blackboxedPositions; + protocol::HashMap>> m_blackboxedPositions; }; } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp similarity index 59% rename from deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp index 387bc4b86693a1..4d84b32cece21b 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp @@ -36,8 +36,12 @@ #include "platform/v8_inspector/InspectedContext.h" #include "platform/v8_inspector/ScriptBreakpoint.h" #include "platform/v8_inspector/V8Compat.h" +#include "platform/v8_inspector/V8ConsoleAgentImpl.h" +#include "platform/v8_inspector/V8ConsoleMessage.h" #include "platform/v8_inspector/V8DebuggerAgentImpl.h" +#include "platform/v8_inspector/V8InjectedScriptHost.h" #include "platform/v8_inspector/V8InspectorSessionImpl.h" +#include "platform/v8_inspector/V8InternalValueType.h" #include "platform/v8_inspector/V8RuntimeAgentImpl.h" #include "platform/v8_inspector/V8StackTraceImpl.h" #include "platform/v8_inspector/V8StringUtil.h" @@ -50,6 +54,9 @@ namespace { const char stepIntoV8MethodName[] = "stepIntoStatement"; const char stepOutV8MethodName[] = "stepOutOfFunction"; volatile int s_lastContextId = 0; +static const char v8AsyncTaskEventEnqueue[] = "enqueue"; +static const char v8AsyncTaskEventWillHandle[] = "willHandle"; +static const char v8AsyncTaskEventDidHandle[] = "didHandle"; inline v8::Local v8Boolean(bool value, v8::Isolate* isolate) { @@ -77,9 +84,12 @@ std::unique_ptr V8Debugger::create(v8::Isolate* isolate, V8DebuggerC V8DebuggerImpl::V8DebuggerImpl(v8::Isolate* isolate, V8DebuggerClient* client) : m_isolate(isolate) , m_client(client) + , m_capturingStackTracesCount(0) + , m_lastExceptionId(0) , m_enabledAgentsCount(0) , m_breakpointsActivated(true) , m_runningNestedMessageLoop(false) + , m_maxAsyncCallStackDepth(0) { } @@ -102,6 +112,7 @@ void V8DebuggerImpl::disable() clearBreakpoints(); m_debuggerScript.Reset(); m_debuggerContext.Reset(); + allAsyncTasksCanceled(); v8::Debug::SetDebugEventListener(m_isolate, nullptr); } @@ -110,7 +121,8 @@ bool V8DebuggerImpl::enabled() const return !m_debuggerScript.IsEmpty(); } -int V8Debugger::contextId(v8::Local context) +// static +int V8DebuggerImpl::contextId(v8::Local context) { v8::Local data = context->GetEmbedderData(static_cast(v8::Context::kDebugIdIndex)); if (data.IsEmpty() || !data->IsString()) @@ -127,7 +139,8 @@ int V8Debugger::contextId(v8::Local context) return dataString.substring(commaPos + 1, commaPos2 - commaPos - 1).toInt(); } -static int getGroupId(v8::Local context) +// static +int V8DebuggerImpl::getGroupId(v8::Local context) { v8::Local data = context->GetEmbedderData(static_cast(v8::Context::kDebugIdIndex)); if (data.IsEmpty() || !data->IsString()) @@ -157,10 +170,13 @@ V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(int contextGroupId { if (!contextGroupId) return nullptr; - V8InspectorSessionImpl* session = m_sessions.get(contextGroupId); - if (session && session->debuggerAgent()->enabled()) - return session->debuggerAgent(); - return nullptr; + SessionMap::iterator it = m_sessions.find(contextGroupId); + if (it == m_sessions.end()) + return nullptr; + V8DebuggerAgentImpl* agent = it->second->debuggerAgent(); + if (!agent->enabled()) + return nullptr; + return agent; } V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(v8::Local context) @@ -168,7 +184,7 @@ V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(v8::Local& result) +void V8DebuggerImpl::getCompiledScripts(int contextGroupId, std::vector>& result) { v8::HandleScope scope(m_isolate); v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); @@ -181,9 +197,11 @@ void V8DebuggerImpl::getCompiledScripts(int contextGroupId, protocol::VectorIsArray()); v8::Local scriptsArray = v8::Local::Cast(value); - result.resize(scriptsArray->Length()); - for (unsigned i = 0; i < scriptsArray->Length(); ++i) - result[i] = createParsedScript(v8::Local::Cast(scriptsArray->Get(v8::Integer::New(m_isolate, i))), true); + result.reserve(scriptsArray->Length()); + for (unsigned i = 0; i < scriptsArray->Length(); ++i) { + v8::Local scriptObject = v8::Local::Cast(scriptsArray->Get(v8::Integer::New(m_isolate, i))); + result.push_back(wrapUnique(new V8DebuggerScript(m_isolate, scriptObject, inLiveEditScope))); + } } String16 V8DebuggerImpl::setBreakpoint(const String16& sourceID, const ScriptBreakpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool interstatementLocation) @@ -298,7 +316,7 @@ void V8DebuggerImpl::breakProgram() v8::HandleScope scope(m_isolate); v8::Local breakFunction; - if (!v8::Function::New(m_isolate->GetCurrentContext(), &V8DebuggerImpl::breakProgramCallback, v8::External::New(m_isolate, this)).ToLocal(&breakFunction)) + if (!v8::Function::New(m_isolate->GetCurrentContext(), &V8DebuggerImpl::breakProgramCallback, v8::External::New(m_isolate, this), 0, v8::ConstructorBehavior::kThrow).ToLocal(&breakFunction)) return; v8::Debug::Call(debuggerContext(), breakFunction).ToLocalChecked(); } @@ -351,7 +369,7 @@ void V8DebuggerImpl::clearStepping() callDebuggerMethod("clearStepping", 0, argv); } -bool V8DebuggerImpl::setScriptSource(const String16& sourceID, const String16& newContent, bool preview, ErrorString* error, Maybe* errorData, JavaScriptCallFrames* newCallFrames, Maybe* stackChanged) +bool V8DebuggerImpl::setScriptSource(const String16& sourceID, v8::Local newSource, bool preview, ErrorString* error, Maybe* exceptionDetails, JavaScriptCallFrames* newCallFrames, Maybe* stackChanged) { class EnableLiveEditScope { public: @@ -376,7 +394,7 @@ bool V8DebuggerImpl::setScriptSource(const String16& sourceID, const String16& n if (!isPaused()) contextScope = wrapUnique(new v8::Context::Scope(debuggerContext())); - v8::Local argv[] = { toV8String(m_isolate, sourceID), toV8String(m_isolate, newContent), v8Boolean(preview, m_isolate) }; + v8::Local argv[] = { toV8String(m_isolate, sourceID), newSource, v8Boolean(preview, m_isolate) }; v8::Local v8result; { @@ -402,17 +420,20 @@ bool V8DebuggerImpl::setScriptSource(const String16& sourceID, const String16& n { *stackChanged = resultTuple->Get(1)->BooleanValue(); // Call stack may have changed after if the edited function was on the stack. - if (!preview && isPaused()) - newCallFrames->swap(currentCallFrames()); + if (!preview && isPaused()) { + JavaScriptCallFrames frames = currentCallFrames(); + newCallFrames->swap(frames); + } return true; } // Compile error. case 1: { - *errorData = protocol::Debugger::SetScriptSourceError::create() - .setMessage(toProtocolStringWithTypeCheck(resultTuple->Get(2))) - .setLineNumber(resultTuple->Get(3)->ToInteger(m_isolate)->Value()) - .setColumnNumber(resultTuple->Get(4)->ToInteger(m_isolate)->Value()).build(); + *exceptionDetails = protocol::Runtime::ExceptionDetails::create() + .setText(toProtocolStringWithTypeCheck(resultTuple->Get(2))) + .setScriptId(String16("0")) + .setLineNumber(resultTuple->Get(3)->ToInteger(m_isolate)->Value() - 1) + .setColumnNumber(resultTuple->Get(4)->ToInteger(m_isolate)->Value() - 1).build(); return false; } } @@ -444,7 +465,7 @@ JavaScriptCallFrames V8DebuggerImpl::currentCallFrames(int limit) if (!callFrameValue->IsObject()) return JavaScriptCallFrames(); v8::Local callFrameObject = callFrameValue.As(); - callFrames.append(JavaScriptCallFrame::create(debuggerContext(), v8::Local::Cast(callFrameObject))); + callFrames.push_back(JavaScriptCallFrame::create(debuggerContext(), v8::Local::Cast(callFrameObject))); } return callFrames; } @@ -475,13 +496,13 @@ void V8DebuggerImpl::handleProgramBreak(v8::Local pausedContext, v8 if (!agent) return; - protocol::Vector breakpointIds; + std::vector breakpointIds; if (!hitBreakpointNumbers.IsEmpty()) { - breakpointIds.resize(hitBreakpointNumbers->Length()); + breakpointIds.reserve(hitBreakpointNumbers->Length()); for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { v8::Local hitBreakpointNumber = hitBreakpointNumbers->Get(i); DCHECK(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt32()); - breakpointIds[i] = String16::number(hitBreakpointNumber->Int32Value()); + breakpointIds.push_back(String16::fromInteger(hitBreakpointNumber->Int32Value())); } } @@ -539,6 +560,12 @@ void V8DebuggerImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDeta v8::Local eventContext = eventDetails.GetEventContext(); DCHECK(!eventContext.IsEmpty()); + if (event == v8::AsyncTaskEvent) { + v8::HandleScope scope(m_isolate); + handleV8AsyncTaskEvent(eventContext, eventDetails.GetExecutionState(), eventDetails.GetEventData()); + return; + } + V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(eventContext); if (agent) { v8::HandleScope scope(m_isolate); @@ -547,8 +574,8 @@ void V8DebuggerImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDeta v8::Local argv[] = { eventDetails.GetEventData() }; v8::Local value = callDebuggerMethod("getAfterCompileScript", 1, argv).ToLocalChecked(); DCHECK(value->IsObject()); - v8::Local object = v8::Local::Cast(value); - agent->didParseSource(createParsedScript(object, event == v8::AfterCompile)); + v8::Local scriptObject = v8::Local::Cast(value); + agent->didParseSource(wrapUnique(new V8DebuggerScript(m_isolate, scriptObject, inLiveEditScope)), event == v8::AfterCompile); } else if (event == v8::Exception) { v8::Local eventData = eventDetails.GetEventData(); v8::Local exception = callInternalGetterFunction(eventData, "exception"); @@ -560,42 +587,35 @@ void V8DebuggerImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDeta v8::Local hitBreakpoints = callDebuggerMethod("getBreakpointNumbers", 1, argv).ToLocalChecked(); DCHECK(hitBreakpoints->IsArray()); handleProgramBreak(eventContext, eventDetails.GetExecutionState(), v8::Local(), hitBreakpoints.As()); - } else if (event == v8::AsyncTaskEvent) { - if (agent->v8AsyncTaskEventsEnabled()) - handleV8AsyncTaskEvent(agent, eventContext, eventDetails.GetExecutionState(), eventDetails.GetEventData()); } } } -void V8DebuggerImpl::handleV8AsyncTaskEvent(V8DebuggerAgentImpl* agent, v8::Local context, v8::Local executionState, v8::Local eventData) +void V8DebuggerImpl::handleV8AsyncTaskEvent(v8::Local context, v8::Local executionState, v8::Local eventData) { + if (!m_maxAsyncCallStackDepth) + return; + String16 type = toProtocolStringWithTypeCheck(callInternalGetterFunction(eventData, "type")); String16 name = toProtocolStringWithTypeCheck(callInternalGetterFunction(eventData, "name")); int id = callInternalGetterFunction(eventData, "id")->ToInteger(m_isolate)->Value(); - agent->didReceiveV8AsyncTaskEvent(context, type, name, id); + // The scopes for the ids are defined by the eventData.name namespaces. There are currently two namespaces: "Object." and "Promise.". + void* ptr = reinterpret_cast(id * 4 + (name[0] == 'P' ? 2 : 0) + 1); + if (type == v8AsyncTaskEventEnqueue) + asyncTaskScheduled(name, ptr, false); + else if (type == v8AsyncTaskEventWillHandle) + asyncTaskStarted(ptr); + else if (type == v8AsyncTaskEventDidHandle) + asyncTaskFinished(ptr); + else + NOTREACHED(); } -V8DebuggerParsedScript V8DebuggerImpl::createParsedScript(v8::Local object, bool success) +V8StackTraceImpl* V8DebuggerImpl::currentAsyncCallChain() { - v8::Local id = object->Get(v8InternalizedString("id")); - DCHECK(!id.IsEmpty() && id->IsInt32()); - - V8DebuggerParsedScript parsedScript; - parsedScript.scriptId = String16::number(id->Int32Value()); - parsedScript.script.setURL(toProtocolStringWithTypeCheck(object->Get(v8InternalizedString("name")))) - .setSourceURL(toProtocolStringWithTypeCheck(object->Get(v8InternalizedString("sourceURL")))) - .setSourceMappingURL(toProtocolStringWithTypeCheck(object->Get(v8InternalizedString("sourceMappingURL")))) - .setSource(toProtocolStringWithTypeCheck(object->Get(v8InternalizedString("source")))) - .setStartLine(object->Get(v8InternalizedString("startLine"))->ToInteger(m_isolate)->Value()) - .setStartColumn(object->Get(v8InternalizedString("startColumn"))->ToInteger(m_isolate)->Value()) - .setEndLine(object->Get(v8InternalizedString("endLine"))->ToInteger(m_isolate)->Value()) - .setEndColumn(object->Get(v8InternalizedString("endColumn"))->ToInteger(m_isolate)->Value()) - .setIsContentScript(object->Get(v8InternalizedString("isContentScript"))->ToBoolean(m_isolate)->Value()) - .setIsInternalScript(object->Get(v8InternalizedString("isInternalScript"))->ToBoolean(m_isolate)->Value()) - .setExecutionContextId(object->Get(v8InternalizedString("executionContextId"))->ToInteger(m_isolate)->Value()) - .setIsLiveEdit(inLiveEditScope); - parsedScript.success = success; - return parsedScript; + if (!m_currentStacks.size()) + return nullptr; + return m_currentStacks.back().get(); } void V8DebuggerImpl::compileDebuggerScript() @@ -634,27 +654,118 @@ v8::MaybeLocal V8DebuggerImpl::functionScopes(v8::Local return v8::Local::New(m_isolate, v8::Undefined(m_isolate)); } v8::Local argv[] = { function }; - return callDebuggerMethod("getFunctionScopes", 1, argv); + v8::Local scopesValue; + if (!callDebuggerMethod("getFunctionScopes", 1, argv).ToLocal(&scopesValue) || !scopesValue->IsArray()) + return v8::MaybeLocal(); + v8::Local scopes = scopesValue.As(); + v8::Local context = m_debuggerContext.Get(m_isolate); + if (!markAsInternal(context, scopes, V8InternalValueType::kScopeList)) + return v8::MaybeLocal(); + if (!markArrayEntriesAsInternal(context, scopes, V8InternalValueType::kScope)) + return v8::MaybeLocal(); + if (!scopes->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false)) + return v8::Undefined(m_isolate); + return scopes; +} + +v8::MaybeLocal V8DebuggerImpl::internalProperties(v8::Local context, v8::Local value) +{ + v8::Local properties; + if (!v8::Debug::GetInternalProperties(m_isolate, value).ToLocal(&properties)) + return v8::MaybeLocal(); + if (value->IsFunction()) { + v8::Local function = value.As(); + v8::Local location = functionLocation(context, function); + if (location->IsObject()) { + properties->Set(properties->Length(), v8InternalizedString("[[FunctionLocation]]")); + properties->Set(properties->Length(), location); + } + if (function->IsGeneratorFunction()) { + properties->Set(properties->Length(), v8InternalizedString("[[IsGenerator]]")); + properties->Set(properties->Length(), v8::True(m_isolate)); + } + } + if (!enabled()) + return properties; + if (value->IsMap() || value->IsWeakMap() || value->IsSet() || value->IsWeakSet() || value->IsSetIterator() || value->IsMapIterator()) { + v8::Local entries = collectionEntries(context, v8::Local::Cast(value)); + if (entries->IsArray()) { + properties->Set(properties->Length(), v8InternalizedString("[[Entries]]")); + properties->Set(properties->Length(), entries); + } + } + if (value->IsGeneratorObject()) { + v8::Local location = generatorObjectLocation(v8::Local::Cast(value)); + if (location->IsObject()) { + properties->Set(properties->Length(), v8InternalizedString("[[GeneratorLocation]]")); + properties->Set(properties->Length(), location); + } + } + if (value->IsFunction()) { + v8::Local function = value.As(); + v8::Local boundFunction = function->GetBoundFunction(); + v8::Local scopes; + if (boundFunction->IsUndefined() && functionScopes(function).ToLocal(&scopes)) { + properties->Set(properties->Length(), v8InternalizedString("[[Scopes]]")); + properties->Set(properties->Length(), scopes); + } + } + return properties; } -v8::Local V8DebuggerImpl::generatorObjectDetails(v8::Local& object) +v8::Local V8DebuggerImpl::collectionEntries(v8::Local context, v8::Local object) { if (!enabled()) { NOTREACHED(); - return v8::Local::New(m_isolate, v8::Undefined(m_isolate)); + return v8::Undefined(m_isolate); } v8::Local argv[] = { object }; - return callDebuggerMethod("getGeneratorObjectDetails", 1, argv).ToLocalChecked(); + v8::Local entriesValue = callDebuggerMethod("getCollectionEntries", 1, argv).ToLocalChecked(); + if (!entriesValue->IsArray()) + return v8::Undefined(m_isolate); + v8::Local entries = entriesValue.As(); + if (!markArrayEntriesAsInternal(context, entries, V8InternalValueType::kEntry)) + return v8::Undefined(m_isolate); + if (!entries->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false)) + return v8::Undefined(m_isolate); + return entries; } -v8::Local V8DebuggerImpl::collectionEntries(v8::Local& object) +v8::Local V8DebuggerImpl::generatorObjectLocation(v8::Local object) { if (!enabled()) { NOTREACHED(); - return v8::Local::New(m_isolate, v8::Undefined(m_isolate)); + return v8::Null(m_isolate); } v8::Local argv[] = { object }; - return callDebuggerMethod("getCollectionEntries", 1, argv).ToLocalChecked(); + v8::Local location = callDebuggerMethod("getGeneratorObjectLocation", 1, argv).ToLocalChecked(); + if (!location->IsObject()) + return v8::Null(m_isolate); + v8::Local context = m_debuggerContext.Get(m_isolate); + if (!markAsInternal(context, v8::Local::Cast(location), V8InternalValueType::kLocation)) + return v8::Null(m_isolate); + return location; +} + +v8::Local V8DebuggerImpl::functionLocation(v8::Local context, v8::Local function) +{ + int scriptId = function->ScriptId(); + if (scriptId == v8::UnboundScript::kNoScriptId) + return v8::Null(m_isolate); + int lineNumber = function->GetScriptLineNumber(); + int columnNumber = function->GetScriptColumnNumber(); + if (lineNumber == v8::Function::kLineOffsetNotFound || columnNumber == v8::Function::kLineOffsetNotFound) + return v8::Null(m_isolate); + v8::Local location = v8::Object::New(m_isolate); + if (!location->Set(context, v8InternalizedString("scriptId"), toV8String(m_isolate, String16::fromInteger(scriptId))).FromMaybe(false)) + return v8::Null(m_isolate); + if (!location->Set(context, v8InternalizedString("lineNumber"), v8::Integer::New(m_isolate, lineNumber)).FromMaybe(false)) + return v8::Null(m_isolate); + if (!location->Set(context, v8InternalizedString("columnNumber"), v8::Integer::New(m_isolate, columnNumber)).FromMaybe(false)) + return v8::Null(m_isolate); + if (!markAsInternal(context, location, V8InternalValueType::kLocation)) + return v8::Null(m_isolate); + return location; } bool V8DebuggerImpl::isPaused() @@ -725,24 +836,59 @@ v8::Local V8DebuggerImpl::compileInternalScript(v8::Localsecond.get(); +} + std::unique_ptr V8DebuggerImpl::createStackTrace(v8::Local stackTrace) { - V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(m_isolate->GetCurrentContext()); - return V8StackTraceImpl::create(agent, stackTrace, V8StackTrace::maxCallStackSizeToCapture); + int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurrentContext()) : 0; + return V8StackTraceImpl::create(this, contextGroupId, stackTrace, V8StackTraceImpl::maxCallStackSizeToCapture); } std::unique_ptr V8DebuggerImpl::connect(int contextGroupId, protocol::FrontendChannel* channel, V8InspectorSessionClient* client, const String16* state) { - DCHECK(!m_sessions.contains(contextGroupId)); - std::unique_ptr session = V8InspectorSessionImpl::create(this, contextGroupId, channel, client, state); - m_sessions.set(contextGroupId, session.get()); + DCHECK(m_sessions.find(contextGroupId) == m_sessions.cend()); + std::unique_ptr session = + V8InspectorSessionImpl::create(this, contextGroupId, channel, client, state); + m_sessions[contextGroupId] = session.get(); return std::move(session); } void V8DebuggerImpl::disconnect(V8InspectorSessionImpl* session) { - DCHECK(m_sessions.contains(session->contextGroupId())); - m_sessions.remove(session->contextGroupId()); + DCHECK(m_sessions.find(session->contextGroupId()) != m_sessions.end()); + m_sessions.erase(session->contextGroupId()); +} + +InspectedContext* V8DebuggerImpl::getContext(int groupId, int contextId) const +{ + ContextsByGroupMap::const_iterator contextGroupIt = m_contexts.find(groupId); + if (contextGroupIt == m_contexts.end()) + return nullptr; + + ContextByIdMap::iterator contextIt = contextGroupIt->second->find(contextId); + if (contextIt == contextGroupIt->second->end()) + return nullptr; + + return contextIt->second.get(); } void V8DebuggerImpl::contextCreated(const V8ContextInfo& info) @@ -750,44 +896,144 @@ void V8DebuggerImpl::contextCreated(const V8ContextInfo& info) DCHECK(info.context->GetIsolate() == m_isolate); // TODO(dgozman): make s_lastContextId non-static. int contextId = atomicIncrement(&s_lastContextId); - String16 debugData = String16::number(info.contextGroupId) + "," + String16::number(contextId) + "," + (info.isDefault ? "default" : "nondefault"); + String16 debugData = String16::fromInteger(info.contextGroupId) + "," + String16::fromInteger(contextId) + "," + (info.isDefault ? "default" : "nondefault"); v8::HandleScope scope(m_isolate); v8::Context::Scope contextScope(info.context); info.context->SetEmbedderData(static_cast(v8::Context::kDebugIdIndex), toV8String(m_isolate, debugData)); - if (!m_contexts.contains(info.contextGroupId)) - m_contexts.set(info.contextGroupId, wrapUnique(new ContextByIdMap())); - DCHECK(!m_contexts.get(info.contextGroupId)->contains(contextId)); + ContextsByGroupMap::iterator contextIt = m_contexts.find(info.contextGroupId); + if (contextIt == m_contexts.end()) + contextIt = m_contexts.insert(std::make_pair(info.contextGroupId, wrapUnique(new ContextByIdMap()))).first; - std::unique_ptr contextOwner(new InspectedContext(this, info, contextId)); - InspectedContext* inspectedContext = contextOwner.get(); - m_contexts.get(info.contextGroupId)->set(contextId, std::move(contextOwner)); + const auto& contextById = contextIt->second; - if (V8InspectorSessionImpl* session = m_sessions.get(info.contextGroupId)) - session->runtimeAgent()->reportExecutionContextCreated(inspectedContext); + DCHECK(contextById->find(contextId) == contextById->cend()); + InspectedContext* context = new InspectedContext(this, info, contextId); + (*contextById)[contextId] = wrapUnique(context); + SessionMap::iterator sessionIt = m_sessions.find(info.contextGroupId); + if (sessionIt != m_sessions.end()) + sessionIt->second->runtimeAgent()->reportExecutionContextCreated(context); } void V8DebuggerImpl::contextDestroyed(v8::Local context) { - int contextId = V8Debugger::contextId(context); + int contextId = V8DebuggerImpl::contextId(context); int contextGroupId = getGroupId(context); - if (!m_contexts.contains(contextGroupId) || !m_contexts.get(contextGroupId)->contains(contextId)) - return; - InspectedContext* inspectedContext = m_contexts.get(contextGroupId)->get(contextId); - if (V8InspectorSessionImpl* session = m_sessions.get(contextGroupId)) - session->runtimeAgent()->reportExecutionContextDestroyed(inspectedContext); + ConsoleStorageMap::iterator storageIt = m_consoleStorageMap.find(contextGroupId); + if (storageIt != m_consoleStorageMap.end()) + storageIt->second->contextDestroyed(contextId); + + InspectedContext* inspectedContext = getContext(contextGroupId, contextId); + if (!inspectedContext) + return; - m_contexts.get(contextGroupId)->remove(contextId); - if (m_contexts.get(contextGroupId)->isEmpty()) - m_contexts.remove(contextGroupId); + SessionMap::iterator iter = m_sessions.find(contextGroupId); + if (iter != m_sessions.end()) + iter->second->runtimeAgent()->reportExecutionContextDestroyed(inspectedContext); + discardInspectedContext(contextGroupId, contextId); } void V8DebuggerImpl::resetContextGroup(int contextGroupId) { - if (V8InspectorSessionImpl* session = m_sessions.get(contextGroupId)) - session->reset(); - m_contexts.remove(contextGroupId); + m_consoleStorageMap.erase(contextGroupId); + SessionMap::iterator session = m_sessions.find(contextGroupId); + if (session != m_sessions.end()) + session->second->reset(); + m_contexts.erase(contextGroupId); +} + +void V8DebuggerImpl::setAsyncCallStackDepth(V8DebuggerAgentImpl* agent, int depth) +{ + if (depth <= 0) + m_maxAsyncCallStackDepthMap.erase(agent); + else + m_maxAsyncCallStackDepthMap[agent] = depth; + + int maxAsyncCallStackDepth = 0; + for (const auto& pair : m_maxAsyncCallStackDepthMap) { + if (pair.second > maxAsyncCallStackDepth) + maxAsyncCallStackDepth = pair.second; + } + + if (m_maxAsyncCallStackDepth == maxAsyncCallStackDepth) + return; + + if (maxAsyncCallStackDepth && !m_maxAsyncCallStackDepth) + m_client->enableAsyncInstrumentation(); + else if (!maxAsyncCallStackDepth && m_maxAsyncCallStackDepth) + m_client->disableAsyncInstrumentation(); + + m_maxAsyncCallStackDepth = maxAsyncCallStackDepth; + if (!maxAsyncCallStackDepth) + allAsyncTasksCanceled(); +} + +void V8DebuggerImpl::asyncTaskScheduled(const String16& taskName, void* task, bool recurring) +{ + if (!m_maxAsyncCallStackDepth) + return; + v8::HandleScope scope(m_isolate); + int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurrentContext()) : 0; + std::unique_ptr chain = V8StackTraceImpl::capture(this, contextGroupId, V8StackTraceImpl::maxCallStackSizeToCapture, taskName); + if (chain) { + m_asyncTaskStacks[task] = std::move(chain); + if (recurring) + m_recurringTasks.insert(task); + } +} + +void V8DebuggerImpl::asyncTaskCanceled(void* task) +{ + if (!m_maxAsyncCallStackDepth) + return; + m_asyncTaskStacks.erase(task); + m_recurringTasks.erase(task); +} + +void V8DebuggerImpl::asyncTaskStarted(void* task) +{ + // Not enabled, return. + if (!m_maxAsyncCallStackDepth) + return; + + m_currentTasks.push_back(task); + AsyncTaskToStackTrace::iterator stackIt = m_asyncTaskStacks.find(task); + // Needs to support following order of events: + // - asyncTaskScheduled + // <-- attached here --> + // - asyncTaskStarted + // - asyncTaskCanceled <-- canceled before finished + // <-- async stack requested here --> + // - asyncTaskFinished + std::unique_ptr stack; + if (stackIt != m_asyncTaskStacks.end() && stackIt->second) + stack = stackIt->second->cloneImpl(); + m_currentStacks.push_back(std::move(stack)); +} + +void V8DebuggerImpl::asyncTaskFinished(void* task) +{ + if (!m_maxAsyncCallStackDepth) + return; + // We could start instrumenting half way and the stack is empty. + if (!m_currentStacks.size()) + return; + + DCHECK(m_currentTasks.back() == task); + m_currentTasks.pop_back(); + + m_currentStacks.pop_back(); + if (m_recurringTasks.find(task) == m_recurringTasks.end()) + m_asyncTaskStacks.erase(task); +} + +void V8DebuggerImpl::allAsyncTasksCanceled() +{ + m_asyncTaskStacks.clear(); + m_recurringTasks.clear(); + m_currentStacks.clear(); + m_currentTasks.clear(); } void V8DebuggerImpl::willExecuteScript(v8::Local context, int scriptId) @@ -812,10 +1058,64 @@ void V8DebuggerImpl::idleFinished() m_isolate->GetCpuProfiler()->SetIdle(false); } -std::unique_ptr V8DebuggerImpl::captureStackTrace(size_t maxStackSize) +void V8DebuggerImpl::logToConsole(v8::Local context, v8::Local arg1, v8::Local arg2) +{ + int contextGroupId = getGroupId(context); + InspectedContext* inspectedContext = getContext(contextGroupId, contextId(context)); + if (!inspectedContext) + return; + std::vector> arguments; + if (!arg1.IsEmpty()) + arguments.push_back(arg1); + if (!arg2.IsEmpty()) + arguments.push_back(arg2); + ensureConsoleMessageStorage(contextGroupId)->addMessage(V8ConsoleMessage::createForConsoleAPI(m_client->currentTimeMS(), ConsoleAPIType::kLog, arguments, captureStackTrace(false), inspectedContext)); +} + +void V8DebuggerImpl::exceptionThrown(int contextGroupId, const String16& errorMessage, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr stackTrace, int scriptId) +{ + unsigned exceptionId = ++m_lastExceptionId; + std::unique_ptr consoleMessage = V8ConsoleMessage::createForException(m_client->currentTimeMS(), errorMessage, url, lineNumber, columnNumber, std::move(stackTrace), scriptId, m_isolate, 0, v8::Local(), exceptionId); + ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMessage)); +} + +unsigned V8DebuggerImpl::promiseRejected(v8::Local context, const String16& errorMessage, v8::Local exception, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr stackTrace, int scriptId) +{ + int contextGroupId = getGroupId(context); + if (!contextGroupId) + return 0; + unsigned exceptionId = ++m_lastExceptionId; + std::unique_ptr consoleMessage = V8ConsoleMessage::createForException(m_client->currentTimeMS(), errorMessage, url, lineNumber, columnNumber, std::move(stackTrace), scriptId, m_isolate, contextId(context), exception, exceptionId); + ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMessage)); + return exceptionId; +} + +void V8DebuggerImpl::promiseRejectionRevoked(v8::Local context, unsigned promiseRejectionId) +{ + int contextGroupId = getGroupId(context); + if (!contextGroupId) + return; + + std::unique_ptr consoleMessage = V8ConsoleMessage::createForRevokedException(m_client->currentTimeMS(), "Handler added to rejected promise", promiseRejectionId); + ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMessage)); +} + +std::unique_ptr V8DebuggerImpl::captureStackTrace(bool fullStack) { - V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(m_isolate->GetCurrentContext()); - return V8StackTraceImpl::capture(agent, maxStackSize); + if (!m_isolate->InContext()) + return nullptr; + + v8::HandleScope handles(m_isolate); + int contextGroupId = getGroupId(m_isolate->GetCurrentContext()); + if (!contextGroupId) + return nullptr; + + size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; + SessionMap::iterator sessionIt = m_sessions.find(contextGroupId); + if (sessionIt != m_sessions.end() && sessionIt->second->runtimeAgent()->enabled()) + stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; + + return V8StackTraceImpl::capture(this, contextGroupId, stackSize); } v8::Local V8DebuggerImpl::regexContext() @@ -827,23 +1127,25 @@ v8::Local V8DebuggerImpl::regexContext() void V8DebuggerImpl::discardInspectedContext(int contextGroupId, int contextId) { - if (!m_contexts.contains(contextGroupId) || !m_contexts.get(contextGroupId)->contains(contextId)) + if (!getContext(contextGroupId, contextId)) return; - m_contexts.get(contextGroupId)->remove(contextId); - if (m_contexts.get(contextGroupId)->isEmpty()) - m_contexts.remove(contextGroupId); + m_contexts[contextGroupId]->erase(contextId); + if (m_contexts[contextGroupId]->empty()) + m_contexts.erase(contextGroupId); } const V8DebuggerImpl::ContextByIdMap* V8DebuggerImpl::contextGroup(int contextGroupId) { - if (!m_contexts.contains(contextGroupId)) - return nullptr; - return m_contexts.get(contextGroupId); + ContextsByGroupMap::iterator iter = m_contexts.find(contextGroupId); + return iter == m_contexts.end() ? nullptr : iter->second.get(); } V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupId) { - return contextGroupId ? m_sessions.get(contextGroupId) : nullptr; + if (!contextGroupId) + return nullptr; + SessionMap::iterator iter = m_sessions.find(contextGroupId); + return iter == m_sessions.end() ? nullptr : iter->second; } } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h similarity index 69% rename from deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h index b62a2a003a5661..0be86bfb28ae52 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h @@ -31,6 +31,7 @@ #ifndef V8DebuggerImpl_h #define V8DebuggerImpl_h +#include "platform/inspector_protocol/Collections.h" #include "platform/inspector_protocol/Maybe.h" #include "platform/inspector_protocol/Platform.h" #include "platform/v8_inspector/JavaScriptCallFrame.h" @@ -40,6 +41,9 @@ #include #include +#include + +#include namespace blink { @@ -47,9 +51,11 @@ using protocol::Maybe; struct ScriptBreakpoint; class InspectedContext; +class V8ConsoleMessageStorage; class V8DebuggerAgentImpl; class V8InspectorSessionImpl; class V8RuntimeAgentImpl; +class V8StackTraceImpl; class V8DebuggerImpl : public V8Debugger { PROTOCOL_DISALLOW_COPY(V8DebuggerImpl); @@ -57,6 +63,9 @@ class V8DebuggerImpl : public V8Debugger { V8DebuggerImpl(v8::Isolate*, V8DebuggerClient*); ~V8DebuggerImpl() override; + static int contextId(v8::Local); + static int getGroupId(v8::Local); + bool enabled() const; String16 setBreakpoint(const String16& sourceID, const ScriptBreakpoint&, int* actualLineNumber, int* actualColumnNumber, bool interstatementLocation); @@ -80,22 +89,24 @@ class V8DebuggerImpl : public V8Debugger { void stepOutOfFunction(); void clearStepping(); - bool setScriptSource(const String16& sourceID, const String16& newContent, bool preview, ErrorString*, Maybe*, JavaScriptCallFrames* newCallFrames, Maybe* stackChanged); + bool setScriptSource(const String16& sourceID, v8::Local newSource, bool preview, ErrorString*, Maybe*, JavaScriptCallFrames* newCallFrames, Maybe* stackChanged); JavaScriptCallFrames currentCallFrames(int limit = 0); // Each script inherits debug data from v8::Context where it has been compiled. // Only scripts whose debug data matches |contextGroupId| will be reported. // Passing 0 will result in reporting all scripts. - void getCompiledScripts(int contextGroupId, protocol::Vector&); + void getCompiledScripts(int contextGroupId, std::vector>&); void debuggerAgentEnabled(); void debuggerAgentDisabled(); - bool isPaused() override; + bool isPaused(); v8::Local pausedContext() { return m_pausedContext; } + int maxAsyncCallChainDepth() { return m_maxAsyncCallStackDepth; } + V8StackTraceImpl* currentAsyncCallChain(); + void setAsyncCallStackDepth(V8DebuggerAgentImpl*, int); v8::MaybeLocal functionScopes(v8::Local); - v8::Local generatorObjectDetails(v8::Local&); - v8::Local collectionEntries(v8::Local&); + v8::MaybeLocal internalProperties(v8::Local, v8::Local); v8::Isolate* isolate() const { return m_isolate; } V8DebuggerClient* client() { return m_client; } @@ -106,6 +117,10 @@ class V8DebuggerImpl : public V8Debugger { v8::Local compileInternalScript(v8::Local, v8::Local, const String16& fileName); v8::Local regexContext(); + void enableStackCapturingIfNeeded(); + void disableStackCapturingIfNeeded(); + V8ConsoleMessageStorage* ensureConsoleMessageStorage(int contextGroupId); + // V8Debugger implementation std::unique_ptr connect(int contextGroupId, protocol::FrontendChannel*, V8InspectorSessionClient*, const String16* state) override; void contextCreated(const V8ContextInfo&) override; @@ -115,14 +130,24 @@ class V8DebuggerImpl : public V8Debugger { void didExecuteScript(v8::Local) override; void idleStarted() override; void idleFinished() override; + void logToConsole(v8::Local, v8::Local arg1, v8::Local arg2) override; + void exceptionThrown(int contextGroupId, const String16& errorMessage, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr, int scriptId) override; + unsigned promiseRejected(v8::Local, const String16& errorMessage, v8::Local exception, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr, int scriptId) override; + void promiseRejectionRevoked(v8::Local, unsigned promiseRejectionId) override; std::unique_ptr createStackTrace(v8::Local) override; - std::unique_ptr captureStackTrace(size_t maxStackSize) override; + std::unique_ptr captureStackTrace(bool fullStack) override; + void asyncTaskScheduled(const String16& taskName, void* task, bool recurring) override; + void asyncTaskCanceled(void* task) override; + void asyncTaskStarted(void* task) override; + void asyncTaskFinished(void* task) override; + void allAsyncTasksCanceled() override; using ContextByIdMap = protocol::HashMap>; void discardInspectedContext(int contextGroupId, int contextId); const ContextByIdMap* contextGroup(int contextGroupId); void disconnect(V8InspectorSessionImpl*); V8InspectorSessionImpl* sessionForContextGroup(int contextGroupId); + InspectedContext* getContext(int groupId, int contextId) const; private: void enable(); @@ -135,8 +160,6 @@ class V8DebuggerImpl : public V8Debugger { v8::Local debuggerContext() const; void clearBreakpoints(); - V8DebuggerParsedScript createParsedScript(v8::Local sourceObject, bool success); - static void breakProgramCallback(const v8::FunctionCallbackInfo&); void handleProgramBreak(v8::Local pausedContext, v8::Local executionState, v8::Local exception, v8::Local hitBreakpoints, bool isPromiseRejection = false); static void v8DebugEventCallback(const v8::Debug::EventDetails&); @@ -145,14 +168,23 @@ class V8DebuggerImpl : public V8Debugger { v8::Local v8InternalizedString(const char*) const; - void handleV8AsyncTaskEvent(V8DebuggerAgentImpl*, v8::Local, v8::Local executionState, v8::Local eventData); + void handleV8AsyncTaskEvent(v8::Local, v8::Local executionState, v8::Local eventData); + + using ContextsByGroupMap = protocol::HashMap>; + + v8::Local collectionEntries(v8::Local, v8::Local); + v8::Local generatorObjectLocation(v8::Local); + v8::Local functionLocation(v8::Local, v8::Local); v8::Isolate* m_isolate; V8DebuggerClient* m_client; - using ContextsByGroupMap = protocol::HashMap>; ContextsByGroupMap m_contexts; using SessionMap = protocol::HashMap; SessionMap m_sessions; + using ConsoleStorageMap = protocol::HashMap>; + ConsoleStorageMap m_consoleStorageMap; + int m_capturingStackTracesCount; + unsigned m_lastExceptionId; int m_enabledAgentsCount; bool m_breakpointsActivated; v8::Global m_debuggerScript; @@ -161,6 +193,14 @@ class V8DebuggerImpl : public V8Debugger { v8::Local m_pausedContext; bool m_runningNestedMessageLoop; v8::Global m_regexContext; + + using AsyncTaskToStackTrace = protocol::HashMap>; + AsyncTaskToStackTrace m_asyncTaskStacks; + protocol::HashSet m_recurringTasks; + int m_maxAsyncCallStackDepth; + std::vector m_currentTasks; + std::vector> m_currentStacks; + protocol::HashMap m_maxAsyncCallStackDepthMap; }; } // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.cpp new file mode 100644 index 00000000000000..91a060b954e023 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.cpp @@ -0,0 +1,121 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "platform/v8_inspector/V8DebuggerScript.h" + +#include "platform/inspector_protocol/Collections.h" +#include "platform/inspector_protocol/Platform.h" +#include "platform/v8_inspector/V8StringUtil.h" + +namespace blink { + +static const LChar hexDigits[17] = "0123456789ABCDEF"; + +static void appendUnsignedAsHex(unsigned number, String16Builder* destination) +{ + for (size_t i = 0; i < 8; ++i) { + destination->append(hexDigits[number & 0xF]); + number >>= 4; + } +} + +// Hash algorithm for substrings is described in "Über die Komplexität der Multiplikation in +// eingeschränkten Branchingprogrammmodellen" by Woelfe. +// http://opendatastructures.org/versions/edition-0.1d/ods-java/node33.html#SECTION00832000000000000000 +static String16 calculateHash(const String16& str) +{ + static uint64_t prime[] = { 0x3FB75161, 0xAB1F4E4F, 0x82675BC5, 0xCD924D35, 0x81ABE279 }; + static uint64_t random[] = { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0 }; + static uint32_t randomOdd[] = { 0xB4663807, 0xCC322BF5, 0xD4F91BBD, 0xA7BEA11D, 0x8F462907 }; + + uint64_t hashes[] = { 0, 0, 0, 0, 0 }; + uint64_t zi[] = { 1, 1, 1, 1, 1 }; + + const size_t hashesSize = PROTOCOL_ARRAY_LENGTH(hashes); + + size_t current = 0; + const uint32_t* data = nullptr; + data = reinterpret_cast(str.characters16()); + for (size_t i = 0; i < str.sizeInBytes() / 4; i += 4) { + uint32_t v = data[i]; + uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; + hashes[current] = (hashes[current] + zi[current] * xi) % prime[current]; + zi[current] = (zi[current] * random[current]) % prime[current]; + current = current == hashesSize - 1 ? 0 : current + 1; + } + if (str.sizeInBytes() % 4) { + uint32_t v = 0; + for (size_t i = str.sizeInBytes() - str.sizeInBytes() % 4; i < str.sizeInBytes(); ++i) { + v <<= 8; + v |= reinterpret_cast(data)[i]; + } + uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; + hashes[current] = (hashes[current] + zi[current] * xi) % prime[current]; + zi[current] = (zi[current] * random[current]) % prime[current]; + current = current == hashesSize - 1 ? 0 : current + 1; + } + + for (size_t i = 0; i < hashesSize; ++i) + hashes[i] = (hashes[i] + zi[i] * (prime[i] - 1)) % prime[i]; + + String16Builder hash; + for (size_t i = 0; i < hashesSize; ++i) + appendUnsignedAsHex(hashes[i], &hash); + return hash.toString(); +} + +V8DebuggerScript::V8DebuggerScript(v8::Isolate* isolate, v8::Local object, bool isLiveEdit) +{ + v8::Local idValue = object->Get(toV8StringInternalized(isolate, "id")); + DCHECK(!idValue.IsEmpty() && idValue->IsInt32()); + m_id = String16::fromInteger(idValue->Int32Value()); + + m_url = toProtocolStringWithTypeCheck(object->Get(toV8StringInternalized(isolate, "name"))); + m_sourceURL = toProtocolStringWithTypeCheck(object->Get(toV8StringInternalized(isolate, "sourceURL"))); + m_sourceMappingURL = toProtocolStringWithTypeCheck(object->Get(toV8StringInternalized(isolate, "sourceMappingURL"))); + m_startLine = object->Get(toV8StringInternalized(isolate, "startLine"))->ToInteger(isolate)->Value(); + m_startColumn = object->Get(toV8StringInternalized(isolate, "startColumn"))->ToInteger(isolate)->Value(); + m_endLine = object->Get(toV8StringInternalized(isolate, "endLine"))->ToInteger(isolate)->Value(); + m_endColumn = object->Get(toV8StringInternalized(isolate, "endColumn"))->ToInteger(isolate)->Value(); + m_isContentScript = object->Get(toV8StringInternalized(isolate, "isContentScript"))->ToBoolean(isolate)->Value(); + m_isInternalScript = object->Get(toV8StringInternalized(isolate, "isInternalScript"))->ToBoolean(isolate)->Value(); + m_executionContextId = object->Get(toV8StringInternalized(isolate, "executionContextId"))->ToInteger(isolate)->Value(); + m_isLiveEdit = isLiveEdit; + + v8::Local sourceValue = object->Get(toV8StringInternalized(isolate, "source")); + if (!sourceValue.IsEmpty() && sourceValue->IsString()) + setSource(isolate, sourceValue.As()); +} + +V8DebuggerScript::~V8DebuggerScript() +{ +} + +String16 V8DebuggerScript::sourceURL() const +{ + return m_sourceURL.isEmpty() ? m_url : m_sourceURL; +} + +v8::Local V8DebuggerScript::source(v8::Isolate* isolate) const +{ + return m_source.Get(isolate); +} + +void V8DebuggerScript::setSourceURL(const String16& sourceURL) +{ + m_sourceURL = sourceURL; +} + +void V8DebuggerScript::setSourceMappingURL(const String16& sourceMappingURL) +{ + m_sourceMappingURL = sourceMappingURL; +} + +void V8DebuggerScript::setSource(v8::Isolate* isolate, v8::Local source) +{ + m_source.Reset(isolate, source); + m_hash = calculateHash(toProtocolString(source)); +} + +} // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8DebuggerScript.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.h similarity index 77% rename from deps/v8_inspector/platform/v8_inspector/V8DebuggerScript.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.h index 55080be0dacea7..60d93d81986493 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8DebuggerScript.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8DebuggerScript.h @@ -37,15 +37,17 @@ namespace blink { class V8DebuggerScript { - PROTOCOL_DISALLOW_NEW(); + PROTOCOL_DISALLOW_COPY(V8DebuggerScript); public: - V8DebuggerScript(); + V8DebuggerScript(v8::Isolate*, v8::Local, bool isLiveEdit); + ~V8DebuggerScript(); + String16 scriptId() const { return m_id; } String16 url() const { return m_url; } bool hasSourceURL() const { return !m_sourceURL.isEmpty(); } String16 sourceURL() const; String16 sourceMappingURL() const { return m_sourceMappingURL; } - String16 source() const { return m_source; } + v8::Local source(v8::Isolate*) const; String16 hash() const { return m_hash; } int startLine() const { return m_startLine; } int startColumn() const { return m_startColumn; } @@ -56,25 +58,16 @@ class V8DebuggerScript { bool isInternalScript() const { return m_isInternalScript; } bool isLiveEdit() const { return m_isLiveEdit; } - V8DebuggerScript& setURL(const String16&); - V8DebuggerScript& setSourceURL(const String16&); - V8DebuggerScript& setSourceMappingURL(const String16&); - V8DebuggerScript& setSource(const String16&); - V8DebuggerScript& setHash(const String16&); - V8DebuggerScript& setStartLine(int); - V8DebuggerScript& setStartColumn(int); - V8DebuggerScript& setEndLine(int); - V8DebuggerScript& setEndColumn(int); - V8DebuggerScript& setExecutionContextId(int); - V8DebuggerScript& setIsContentScript(bool); - V8DebuggerScript& setIsInternalScript(bool); - V8DebuggerScript& setIsLiveEdit(bool); + void setSourceURL(const String16&); + void setSourceMappingURL(const String16&); + void setSource(v8::Isolate*, v8::Local); private: + String16 m_id; String16 m_url; String16 m_sourceURL; String16 m_sourceMappingURL; - String16 m_source; + v8::Global m_source; String16 m_hash; int m_startLine; int m_startColumn; @@ -86,12 +79,6 @@ class V8DebuggerScript { bool m_isLiveEdit; }; -struct V8DebuggerParsedScript { - String16 scriptId; - V8DebuggerScript script; - bool success; -}; - } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp similarity index 92% rename from deps/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp index 83e24d79be63fc..73edc7260f0719 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp @@ -50,27 +50,27 @@ V8FunctionCall::V8FunctionCall(V8DebuggerImpl* debugger, v8::Local void V8FunctionCall::appendArgument(v8::Local value) { - m_arguments.append(value); + m_arguments.push_back(value); } void V8FunctionCall::appendArgument(const String16& argument) { - m_arguments.append(toV8String(m_context->GetIsolate(), argument)); + m_arguments.push_back(toV8String(m_context->GetIsolate(), argument)); } void V8FunctionCall::appendArgument(int argument) { - m_arguments.append(v8::Number::New(m_context->GetIsolate(), argument)); + m_arguments.push_back(v8::Number::New(m_context->GetIsolate(), argument)); } void V8FunctionCall::appendArgument(bool argument) { - m_arguments.append(argument ? v8::True(m_context->GetIsolate()) : v8::False(m_context->GetIsolate())); + m_arguments.push_back(argument ? v8::True(m_context->GetIsolate()) : v8::False(m_context->GetIsolate())); } void V8FunctionCall::appendUndefinedArgument() { - m_arguments.append(v8::Undefined(m_context->GetIsolate())); + m_arguments.push_back(v8::Undefined(m_context->GetIsolate())); } v8::Local V8FunctionCall::call(bool& hadException, bool reportExceptions) diff --git a/deps/v8_inspector/platform/v8_inspector/V8FunctionCall.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.h similarity index 95% rename from deps/v8_inspector/platform/v8_inspector/V8FunctionCall.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.h index 1c94d240aa91de..0b9d4e2a5096f1 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8FunctionCall.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8FunctionCall.h @@ -31,7 +31,6 @@ #ifndef V8FunctionCall_h #define V8FunctionCall_h -#include "platform/inspector_protocol/Collections.h" #include "platform/inspector_protocol/String16.h" #include @@ -58,7 +57,7 @@ class V8FunctionCall { protected: V8DebuggerImpl* m_debugger; v8::Local m_context; - protocol::Vector> m_arguments; + std::vector> m_arguments; v8::Local m_name; v8::Local m_value; }; diff --git a/deps/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp similarity index 95% rename from deps/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp index 3281d1ba1dab48..240dc3d27492e9 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp @@ -45,14 +45,12 @@ class HeapSnapshotProgress final : public v8::ActivityControl { class GlobalObjectNameResolver final : public v8::HeapProfiler::ObjectNameResolver { public: - explicit GlobalObjectNameResolver(V8InspectorSessionImpl* session) : m_offset(0), m_session(session) - { - m_strings.resize(10000); - } + explicit GlobalObjectNameResolver(V8InspectorSessionImpl* session) + : m_offset(0), m_strings(10000), m_session(session) {} const char* GetName(v8::Local object) override { - int contextId = V8Debugger::contextId(object->CreationContext()); + int contextId = V8DebuggerImpl::contextId(object->CreationContext()); if (!contextId) return ""; ErrorString errorString; @@ -75,7 +73,7 @@ class GlobalObjectNameResolver final : public v8::HeapProfiler::ObjectNameResolv private: size_t m_offset; - protocol::Vector m_strings; + std::vector m_strings; V8InspectorSessionImpl* m_session; }; @@ -171,7 +169,7 @@ void V8HeapProfilerAgentImpl::restore() #if V8_MAJOR_VERSION >= 5 if (m_state->booleanProperty(HeapProfilerAgentState::samplingHeapProfilerEnabled, false)) { ErrorString error; - double samplingInterval = m_state->numberProperty(HeapProfilerAgentState::samplingHeapProfilerInterval, -1); + double samplingInterval = m_state->doubleProperty(HeapProfilerAgentState::samplingHeapProfilerInterval, -1); DCHECK_GE(samplingInterval, 0); startSampling(&error, Maybe(samplingInterval)); } @@ -260,7 +258,7 @@ void V8HeapProfilerAgentImpl::getObjectByHeapObjectId(ErrorString* error, const return; } - *result = m_session->wrapObject(heapObject->CreationContext(), heapObject, objectGroup.fromMaybe("")); + *result = m_session->wrapObject(heapObject->CreationContext(), heapObject, objectGroup.fromMaybe(""), false); if (!result) *error = "Object is not available"; } @@ -297,7 +295,7 @@ void V8HeapProfilerAgentImpl::getHeapObjectId(ErrorString* errorString, const St return; v8::SnapshotObjectId id = m_isolate->GetHeapProfiler()->GetObjectId(value); - *heapSnapshotObjectId = String16::number(id); + *heapSnapshotObjectId = String16::fromInteger(id); } void V8HeapProfilerAgentImpl::requestHeapStatsUpdate() @@ -343,7 +341,7 @@ void V8HeapProfilerAgentImpl::startSampling(ErrorString* errorString, const Mayb } const unsigned defaultSamplingInterval = 1 << 15; double samplingIntervalValue = samplingInterval.fromMaybe(defaultSamplingInterval); - m_state->setNumber(HeapProfilerAgentState::samplingHeapProfilerInterval, samplingIntervalValue); + m_state->setDouble(HeapProfilerAgentState::samplingHeapProfilerInterval, samplingIntervalValue); m_state->setBoolean(HeapProfilerAgentState::samplingHeapProfilerEnabled, true); #if V8_MAJOR_VERSION * 1000 + V8_MINOR_VERSION >= 5002 profiler->StartSamplingHeapProfiler(static_cast(samplingIntervalValue), 128, v8::HeapProfiler::kSamplingForceGC); @@ -363,12 +361,15 @@ std::unique_ptr buildSampingHea size_t selfSize = 0; for (const auto& allocation : node->allocations) selfSize += allocation.size * allocation.count; - std::unique_ptr result = protocol::HeapProfiler::SamplingHeapProfileNode::create() + std::unique_ptr callFrame = protocol::Runtime::CallFrame::create() .setFunctionName(toProtocolString(node->name)) - .setScriptId(String16::number(node->script_id)) + .setScriptId(String16::fromInteger(node->script_id)) .setUrl(toProtocolString(node->script_name)) - .setLineNumber(node->line_number) - .setColumnNumber(node->column_number) + .setLineNumber(node->line_number - 1) + .setColumnNumber(node->column_number - 1) + .build(); + std::unique_ptr result = protocol::HeapProfiler::SamplingHeapProfileNode::create() + .setCallFrame(std::move(callFrame)) .setSelfSize(selfSize) .setChildren(std::move(children)).build(); return result; diff --git a/deps/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.h similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.h diff --git a/deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp similarity index 90% rename from deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp index e7f9bed382349b..afa5138f6ec245 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp @@ -8,6 +8,7 @@ #include "platform/v8_inspector/InjectedScriptNative.h" #include "platform/v8_inspector/V8Compat.h" #include "platform/v8_inspector/V8DebuggerImpl.h" +#include "platform/v8_inspector/V8InternalValueType.h" #include "platform/v8_inspector/V8StringUtil.h" #include "platform/v8_inspector/public/V8DebuggerClient.h" @@ -19,7 +20,7 @@ void setFunctionProperty(v8::Local context, v8::Local o { v8::Local funcName = toV8StringInternalized(context->GetIsolate(), name); v8::Local func; - if (!v8::Function::New(context, callback, external).ToLocal(&func)) + if (!v8::Function::New(context, callback, external, 0, v8::ConstructorBehavior::kThrow).ToLocal(&func)) return; func->SetName(funcName); if (!obj->Set(context, funcName, func).FromMaybe(false)) @@ -46,7 +47,6 @@ v8::Local V8InjectedScriptHost::create(v8::Local contex setFunctionProperty(context, injectedScriptHost, "formatAccessorsAsProperties", V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal); setFunctionProperty(context, injectedScriptHost, "isTypedArray", V8InjectedScriptHost::isTypedArrayCallback, debuggerExternal); setFunctionProperty(context, injectedScriptHost, "subtype", V8InjectedScriptHost::subtypeCallback, debuggerExternal); - setFunctionProperty(context, injectedScriptHost, "collectionEntries", V8InjectedScriptHost::collectionEntriesCallback, debuggerExternal); setFunctionProperty(context, injectedScriptHost, "getInternalProperties", V8InjectedScriptHost::getInternalPropertiesCallback, debuggerExternal); setFunctionProperty(context, injectedScriptHost, "suppressWarningsAndCallFunction", V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback, debuggerExternal); setFunctionProperty(context, injectedScriptHost, "bind", V8InjectedScriptHost::bindCallback, debuggerExternal); @@ -91,6 +91,13 @@ void V8InjectedScriptHost::subtypeCallback(const v8::FunctionCallbackInfo value = info[0]; + if (value->IsObject()) { + v8::Local internalType = v8InternalValueTypeFrom(isolate->GetCurrentContext(), v8::Local::Cast(value)); + if (internalType->IsString()) { + info.GetReturnValue().Set(internalType); + return; + } + } if (value->IsArray() || value->IsTypedArray() || value->IsArgumentsObject()) { info.GetReturnValue().Set(toV8StringInternalized(isolate, "array")); return; @@ -134,23 +141,12 @@ void V8InjectedScriptHost::subtypeCallback(const v8::FunctionCallbackInfo& info) -{ - if (info.Length() < 1 || !info[0]->IsObject()) - return; - - v8::Local object = info[0].As(); - info.GetReturnValue().Set(unwrapDebugger(info)->collectionEntries(object)); -} - void V8InjectedScriptHost::getInternalPropertiesCallback(const v8::FunctionCallbackInfo& info) { - if (info.Length() < 1 || !info[0]->IsObject()) + if (info.Length() < 1) return; - - v8::Local object = info[0].As(); v8::Local properties; - if (v8::Debug::GetInternalProperties(info.GetIsolate(), object).ToLocal(&properties)) + if (unwrapDebugger(info)->internalProperties(info.GetIsolate()->GetCurrentContext(), info[0]).ToLocal(&properties)) info.GetReturnValue().Set(properties); } @@ -183,15 +179,18 @@ void V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback(const v8::Fun } } - V8DebuggerClient* client = unwrapDebugger(info)->client(); - client->muteWarningsAndDeprecations(); + V8DebuggerImpl* debugger = unwrapDebugger(info); + int contextGroupId = V8DebuggerImpl::getGroupId(context); + if (contextGroupId) + debugger->client()->muteWarningsAndDeprecations(contextGroupId); v8::MicrotasksScope microtasks(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Local result; if (function->Call(context, receiver, argc, argv.get()).ToLocal(&result)) info.GetReturnValue().Set(result); - client->unmuteWarningsAndDeprecations(); + if (contextGroupId) + debugger->client()->unmuteWarningsAndDeprecations(contextGroupId); } void V8InjectedScriptHost::bindCallback(const v8::FunctionCallbackInfo& info) diff --git a/deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h similarity index 95% rename from deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h index d21bbdd33e3d28..bf49fa71f40cea 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h @@ -21,13 +21,11 @@ class V8InjectedScriptHost { // We expect that debugger outlives any JS context and thus V8InjectedScriptHost (owned by JS) // is destroyed before debugger. static v8::Local create(v8::Local, V8DebuggerImpl*); - private: static void internalConstructorNameCallback(const v8::FunctionCallbackInfo&); static void formatAccessorsAsProperties(const v8::FunctionCallbackInfo&); static void isTypedArrayCallback(const v8::FunctionCallbackInfo&); static void subtypeCallback(const v8::FunctionCallbackInfo&); - static void collectionEntriesCallback(const v8::FunctionCallbackInfo&); static void getInternalPropertiesCallback(const v8::FunctionCallbackInfo&); static void suppressWarningsAndCallFunctionCallback(const v8::FunctionCallbackInfo&); static void bindCallback(const v8::FunctionCallbackInfo&); diff --git a/deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp similarity index 81% rename from deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp index 1c584e713e07b3..88aac8c894d41a 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp @@ -8,6 +8,7 @@ #include "platform/v8_inspector/InjectedScript.h" #include "platform/v8_inspector/InspectedContext.h" #include "platform/v8_inspector/RemoteObjectId.h" +#include "platform/v8_inspector/V8ConsoleAgentImpl.h" #include "platform/v8_inspector/V8DebuggerAgentImpl.h" #include "platform/v8_inspector/V8DebuggerImpl.h" #include "platform/v8_inspector/V8HeapProfilerAgentImpl.h" @@ -23,7 +24,7 @@ const char V8InspectorSession::backtraceObjectGroup[] = "backtrace"; // static bool V8InspectorSession::isV8ProtocolMethod(const String16& method) { - return method.startWith("Debugger.") || method.startWith("HeapProfiler.") || method.startWith("Profiler.") || method.startWith("Runtime."); + return method.startWith("Debugger.") || method.startWith("HeapProfiler.") || method.startWith("Profiler.") || method.startWith("Runtime.") || method.startWith("Console."); } std::unique_ptr V8InspectorSessionImpl::create(V8DebuggerImpl* debugger, int contextGroupId, protocol::FrontendChannel* channel, V8InspectorSessionClient* client, const String16* state) @@ -36,13 +37,13 @@ V8InspectorSessionImpl::V8InspectorSessionImpl(V8DebuggerImpl* debugger, int con , m_debugger(debugger) , m_client(client) , m_customObjectFormatterEnabled(false) - , m_instrumentationCounter(0) , m_dispatcher(channel) , m_state(nullptr) , m_runtimeAgent(nullptr) , m_debuggerAgent(nullptr) , m_heapProfilerAgent(nullptr) , m_profilerAgent(nullptr) + , m_consoleAgent(nullptr) { if (savedState) { std::unique_ptr state = protocol::parseJSON(*savedState); @@ -66,17 +67,22 @@ V8InspectorSessionImpl::V8InspectorSessionImpl(V8DebuggerImpl* debugger, int con m_heapProfilerAgent = wrapUnique(new V8HeapProfilerAgentImpl(this, channel, agentState(protocol::HeapProfiler::Metainfo::domainName))); protocol::HeapProfiler::Dispatcher::wire(&m_dispatcher, m_heapProfilerAgent.get()); + m_consoleAgent = wrapUnique(new V8ConsoleAgentImpl(this, channel, agentState(protocol::Console::Metainfo::domainName))); + protocol::Console::Dispatcher::wire(&m_dispatcher, m_consoleAgent.get()); + if (savedState) { m_runtimeAgent->restore(); m_debuggerAgent->restore(); m_heapProfilerAgent->restore(); m_profilerAgent->restore(); + m_consoleAgent->restore(); } } V8InspectorSessionImpl::~V8InspectorSessionImpl() { ErrorString errorString; + m_consoleAgent->disable(&errorString); m_profilerAgent->disable(&errorString); m_heapProfilerAgent->disable(&errorString); m_debuggerAgent->disable(&errorString); @@ -111,13 +117,17 @@ void V8InspectorSessionImpl::discardInjectedScripts() if (!contexts) return; - protocol::Vector keys; + std::vector keys; + keys.reserve(contexts->size()); for (auto& idContext : *contexts) - keys.append(idContext.first); + keys.push_back(idContext.first); for (auto& key : keys) { contexts = m_debugger->contextGroup(m_contextGroupId); - if (contexts && contexts->contains(key)) - contexts->get(key)->discardInjectedScript(); // This may destroy some contexts. + if (!contexts) + continue; + auto contextIt = contexts->find(key); + if (contextIt != contexts->end()) + contextIt->second->discardInjectedScript(); // This may destroy some contexts. } } @@ -129,12 +139,13 @@ InjectedScript* V8InspectorSessionImpl::findInjectedScript(ErrorString* errorStr } const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_contextGroupId); - if (!contexts || !contexts->contains(contextId)) { + auto contextsIt = contexts ? contexts->find(contextId) : contexts->end(); + if (contextsIt == contexts->end()) { *errorString = "Cannot find context with specified id"; return nullptr; } - InspectedContext* context = contexts->get(contextId); + const std::unique_ptr& context = contextsIt->second; if (!context->getInjectedScript()) { context->createInjectedScript(); if (!context->getInjectedScript()) { @@ -158,16 +169,19 @@ void V8InspectorSessionImpl::releaseObjectGroup(const String16& objectGroup) if (!contexts) return; - protocol::Vector keys; + std::vector keys; for (auto& idContext : *contexts) - keys.append(idContext.first); + keys.push_back(idContext.first); for (auto& key : keys) { contexts = m_debugger->contextGroup(m_contextGroupId); - if (contexts && contexts->contains(key)) { - InjectedScript* injectedScript = contexts->get(key)->getInjectedScript(); - if (injectedScript) - injectedScript->releaseObjectGroup(objectGroup); // This may destroy some contexts. - } + if (!contexts) + continue; + auto contextsIt = contexts->find(key); + if (contextsIt == contexts->end()) + continue; + InjectedScript* injectedScript = contextsIt->second->getInjectedScript(); + if (injectedScript) + injectedScript->releaseObjectGroup(objectGroup); // This may destroy some contexts. } } @@ -193,7 +207,7 @@ v8::Local V8InspectorSessionImpl::findObject(ErrorString* errorString std::unique_ptr V8InspectorSessionImpl::wrapObject(v8::Local context, v8::Local value, const String16& groupName, bool generatePreview) { ErrorString errorString; - InjectedScript* injectedScript = findInjectedScript(&errorString, V8Debugger::contextId(context)); + InjectedScript* injectedScript = findInjectedScript(&errorString, V8DebuggerImpl::contextId(context)); if (!injectedScript) return nullptr; return injectedScript->wrapObject(&errorString, value, groupName, false, generatePreview); @@ -202,7 +216,7 @@ std::unique_ptr V8InspectorSessionImpl::wrapObj std::unique_ptr V8InspectorSessionImpl::wrapTable(v8::Local context, v8::Local table, v8::Local columns) { ErrorString errorString; - InjectedScript* injectedScript = findInjectedScript(&errorString, V8Debugger::contextId(context)); + InjectedScript* injectedScript = findInjectedScript(&errorString, V8DebuggerImpl::contextId(context)); if (!injectedScript) return nullptr; return injectedScript->wrapTable(table, columns); @@ -227,17 +241,7 @@ void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent) if (!contexts) return; for (auto& idContext : *contexts) - agent->reportExecutionContextCreated(idContext.second); -} - -void V8InspectorSessionImpl::changeInstrumentationCounter(int delta) -{ - DCHECK_GE(m_instrumentationCounter + delta, 0); - if (!m_instrumentationCounter) - m_client->startInstrumenting(); - m_instrumentationCounter += delta; - if (!m_instrumentationCounter) - m_client->stopInstrumenting(); + agent->reportExecutionContextCreated(idContext.second.get()); } void V8InspectorSessionImpl::dispatchProtocolMessage(const String16& message) @@ -252,16 +256,16 @@ String16 V8InspectorSessionImpl::stateJSON() void V8InspectorSessionImpl::addInspectedObject(std::unique_ptr inspectable) { - m_inspectedObjects.prepend(std::move(inspectable)); - while (m_inspectedObjects.size() > kInspectedObjectBufferSize) - m_inspectedObjects.removeLast(); + m_inspectedObjects.insert(m_inspectedObjects.begin(), std::move(inspectable)); + if (m_inspectedObjects.size() > kInspectedObjectBufferSize) + m_inspectedObjects.resize(kInspectedObjectBufferSize); } V8InspectorSession::Inspectable* V8InspectorSessionImpl::inspectedObject(unsigned num) { if (num >= m_inspectedObjects.size()) return nullptr; - return m_inspectedObjects[num]; + return m_inspectedObjects[num].get(); } void V8InspectorSessionImpl::schedulePauseOnNextStatement(const String16& breakReason, std::unique_ptr data) @@ -279,11 +283,6 @@ void V8InspectorSessionImpl::breakProgram(const String16& breakReason, std::uniq m_debuggerAgent->breakProgram(breakReason, std::move(data)); } -void V8InspectorSessionImpl::breakProgramOnException(const String16& breakReason, std::unique_ptr data) -{ - m_debuggerAgent->breakProgramOnException(breakReason, std::move(data)); -} - void V8InspectorSessionImpl::setSkipAllPauses(bool skip) { ErrorString errorString; @@ -302,29 +301,4 @@ void V8InspectorSessionImpl::stepOver() m_debuggerAgent->stepOver(&errorString); } -void V8InspectorSessionImpl::asyncTaskScheduled(const String16& taskName, void* task, bool recurring) -{ - m_debuggerAgent->asyncTaskScheduled(taskName, task, recurring); -} - -void V8InspectorSessionImpl::asyncTaskCanceled(void* task) -{ - m_debuggerAgent->asyncTaskCanceled(task); -} - -void V8InspectorSessionImpl::asyncTaskStarted(void* task) -{ - m_debuggerAgent->asyncTaskStarted(task); -} - -void V8InspectorSessionImpl::asyncTaskFinished(void* task) -{ - m_debuggerAgent->asyncTaskFinished(task); -} - -void V8InspectorSessionImpl::allAsyncTasksCanceled() -{ - m_debuggerAgent->allAsyncTasksCanceled(); -} - } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h similarity index 84% rename from deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h index bf90eb241dafaf..21753dac21b98a 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h @@ -6,7 +6,6 @@ #define V8InspectorSessionImpl_h #include "platform/inspector_protocol/Allocator.h" -#include "platform/inspector_protocol/Collections.h" #include "platform/inspector_protocol/DispatcherBase.h" #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" @@ -16,10 +15,13 @@ #include +#include + namespace blink { class InjectedScript; class RemoteObjectIdBase; +class V8ConsoleAgentImpl; class V8DebuggerAgentImpl; class V8DebuggerImpl; class V8HeapProfilerAgentImpl; @@ -34,6 +36,7 @@ class V8InspectorSessionImpl : public V8InspectorSession { V8DebuggerImpl* debugger() const { return m_debugger; } V8InspectorSessionClient* client() const { return m_client; } + V8ConsoleAgentImpl* consoleAgent() { return m_consoleAgent.get(); } V8DebuggerAgentImpl* debuggerAgent() { return m_debuggerAgent.get(); } V8ProfilerAgentImpl* profilerAgent() { return m_profilerAgent.get(); } V8RuntimeAgentImpl* runtimeAgent() { return m_runtimeAgent.get(); } @@ -45,7 +48,6 @@ class V8InspectorSessionImpl : public V8InspectorSession { void discardInjectedScripts(); void reportAllContexts(V8RuntimeAgentImpl*); void setCustomObjectFormatterEnabled(bool); - void changeInstrumentationCounter(int delta); // V8InspectorSession implementation. void dispatchProtocolMessage(const String16& message) override; @@ -54,19 +56,13 @@ class V8InspectorSessionImpl : public V8InspectorSession { void schedulePauseOnNextStatement(const String16& breakReason, std::unique_ptr data) override; void cancelPauseOnNextStatement() override; void breakProgram(const String16& breakReason, std::unique_ptr data) override; - void breakProgramOnException(const String16& breakReason, std::unique_ptr data) override; void setSkipAllPauses(bool) override; void resume() override; void stepOver() override; - void asyncTaskScheduled(const String16& taskName, void* task, bool recurring) override; - void asyncTaskCanceled(void* task) override; - void asyncTaskStarted(void* task) override; - void asyncTaskFinished(void* task) override; - void allAsyncTasksCanceled() override; void releaseObjectGroup(const String16& objectGroup) override; v8::Local findObject(ErrorString*, const String16& objectId, v8::Local* = nullptr, String16* groupName = nullptr) override; - std::unique_ptr wrapObject(v8::Local, v8::Local, const String16& groupName, bool generatePreview = false) override; - std::unique_ptr wrapTable(v8::Local, v8::Local table, v8::Local columns) override; + std::unique_ptr wrapObject(v8::Local, v8::Local, const String16& groupName, bool generatePreview) override; + std::unique_ptr wrapTable(v8::Local, v8::Local table, v8::Local columns); V8InspectorSession::Inspectable* inspectedObject(unsigned num); static const unsigned kInspectedObjectBufferSize = 5; @@ -79,7 +75,6 @@ class V8InspectorSessionImpl : public V8InspectorSession { V8DebuggerImpl* m_debugger; V8InspectorSessionClient* m_client; bool m_customObjectFormatterEnabled; - int m_instrumentationCounter; protocol::UberDispatcher m_dispatcher; std::unique_ptr m_state; @@ -88,7 +83,8 @@ class V8InspectorSessionImpl : public V8InspectorSession { std::unique_ptr m_debuggerAgent; std::unique_ptr m_heapProfilerAgent; std::unique_ptr m_profilerAgent; - protocol::Vector> m_inspectedObjects; + std::unique_ptr m_consoleAgent; + std::vector> m_inspectedObjects; }; } // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InternalValueType.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InternalValueType.cpp new file mode 100644 index 00000000000000..52e7677fd709e2 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InternalValueType.cpp @@ -0,0 +1,72 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "platform/v8_inspector/V8InternalValueType.h" + +#include "platform/inspector_protocol/Platform.h" +#include "platform/v8_inspector/V8StringUtil.h" + +namespace blink { + +namespace { + +v8::Local internalSubtypePrivate(v8::Isolate* isolate) +{ + return v8::Private::ForApi(isolate, toV8StringInternalized(isolate, "V8InternalType#internalSubtype")); +} + +v8::Local subtypeForInternalType(v8::Isolate* isolate, V8InternalValueType type) +{ + switch (type) { + case V8InternalValueType::kEntry: + return toV8StringInternalized(isolate, "internal#entry"); + case V8InternalValueType::kLocation: + return toV8StringInternalized(isolate, "internal#location"); + case V8InternalValueType::kScope: + return toV8StringInternalized(isolate, "internal#scope"); + case V8InternalValueType::kScopeList: + return toV8StringInternalized(isolate, "internal#scopeList"); + } + NOTREACHED(); + return v8::Local(); +} + +} // namespace + +bool markAsInternal(v8::Local context, v8::Local object, V8InternalValueType type) +{ + v8::Isolate* isolate = context->GetIsolate(); + v8::Local privateValue = internalSubtypePrivate(isolate); + v8::Local subtype = subtypeForInternalType(isolate, type); + return object->SetPrivate(context, privateValue, subtype).FromMaybe(false); +} + +bool markArrayEntriesAsInternal(v8::Local context, v8::Local array, V8InternalValueType type) +{ + v8::Isolate* isolate = context->GetIsolate(); + v8::Local privateValue = internalSubtypePrivate(isolate); + v8::Local subtype = subtypeForInternalType(isolate, type); + for (size_t i = 0; i < array->Length(); ++i) { + v8::Local entry; + if (!array->Get(context, i).ToLocal(&entry) || !entry->IsObject()) + return false; + if (!entry.As()->SetPrivate(context, privateValue, subtype).FromMaybe(false)) + return false; + } + return true; +} + +v8::Local v8InternalValueTypeFrom(v8::Local context, v8::Local object) +{ + v8::Isolate* isolate = context->GetIsolate(); + v8::Local privateValue = internalSubtypePrivate(isolate); + if (!object->HasPrivate(context, privateValue).FromMaybe(false)) + return v8::Null(isolate); + v8::Local subtypeValue; + if (!object->GetPrivate(context, privateValue).ToLocal(&subtypeValue) || !subtypeValue->IsString()) + return v8::Null(isolate); + return subtypeValue; +} + +} // namespace blink diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InternalValueType.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InternalValueType.h new file mode 100644 index 00000000000000..4bb71720f055c4 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8InternalValueType.h @@ -0,0 +1,21 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8InternalValueType_h +#define V8InternalValueType_h + +#include + +namespace blink { + +enum class V8InternalValueType { kEntry, kLocation, kScope, kScopeList }; + +bool markAsInternal(v8::Local, v8::Local, V8InternalValueType); +bool markArrayEntriesAsInternal(v8::Local, v8::Local, V8InternalValueType); +v8::Local v8InternalValueTypeFrom(v8::Local, v8::Local); + + +} // namespace blink + +#endif // V8InternalValueType_h diff --git a/deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp similarity index 90% rename from deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp index 92762f73dc8e9d..0761f87e0d7a26 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp @@ -11,6 +11,8 @@ #include "platform/v8_inspector/V8StringUtil.h" #include +#include + namespace blink { namespace ProfilerAgentState { @@ -28,7 +30,7 @@ std::unique_ptr> buildInsp if (!lineCount) return array; - protocol::Vector entries(lineCount); + std::vector entries(lineCount); if (node->GetLineTicks(&entries[0], lineCount)) { for (unsigned i = 0; i < lineCount; i++) { std::unique_ptr line = protocol::Profiler::PositionTickInfo::create() @@ -54,14 +56,16 @@ std::unique_ptr buildInspectorObjectFor(v8:: std::unique_ptr> positionTicks = buildInspectorObjectForPositionTicks(node); - std::unique_ptr result = protocol::Profiler::CPUProfileNode::create() + std::unique_ptr callFrame = protocol::Runtime::CallFrame::create() .setFunctionName(toProtocolString(node->GetFunctionName())) - .setScriptId(String16::number(node->GetScriptId())) + .setScriptId(String16::fromInteger(node->GetScriptId())) .setUrl(toProtocolString(node->GetScriptResourceName())) - .setLineNumber(node->GetLineNumber()) - .setColumnNumber(node->GetColumnNumber()) + .setLineNumber(node->GetLineNumber() - 1) + .setColumnNumber(node->GetColumnNumber() - 1) + .build(); + std::unique_ptr result = protocol::Profiler::CPUProfileNode::create() + .setCallFrame(std::move(callFrame)) .setHitCount(node->GetHitCount()) - .setCallUID(node->GetCallUid()) .setChildren(std::move(children)) .setPositionTicks(std::move(positionTicks)) .setDeoptReason(node->GetBailoutReason()) @@ -140,7 +144,7 @@ void V8ProfilerAgentImpl::consoleProfile(const String16& title) if (!m_enabled) return; String16 id = nextProfileId(); - m_startedProfiles.append(ProfileDescriptor(id, title)); + m_startedProfiles.push_back(ProfileDescriptor(id, title)); startProfiling(id); m_frontend.consoleProfileStarted(id, currentDebugLocation(m_session->debugger()), title); } @@ -153,17 +157,17 @@ void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title) String16 resolvedTitle; // Take last started profile if no title was passed. if (title.isEmpty()) { - if (m_startedProfiles.isEmpty()) + if (m_startedProfiles.empty()) return; - id = m_startedProfiles.last().m_id; - resolvedTitle = m_startedProfiles.last().m_title; - m_startedProfiles.removeLast(); + id = m_startedProfiles.back().m_id; + resolvedTitle = m_startedProfiles.back().m_title; + m_startedProfiles.pop_back(); } else { for (size_t i = 0; i < m_startedProfiles.size(); i++) { if (m_startedProfiles[i].m_title == title) { resolvedTitle = title; id = m_startedProfiles[i].m_id; - m_startedProfiles.remove(i); + m_startedProfiles.erase(m_startedProfiles.begin() + i); break; } } @@ -183,14 +187,12 @@ void V8ProfilerAgentImpl::enable(ErrorString*) return; m_enabled = true; m_state->setBoolean(ProfilerAgentState::profilerEnabled, true); - m_session->changeInstrumentationCounter(+1); } void V8ProfilerAgentImpl::disable(ErrorString* errorString) { if (!m_enabled) return; - m_session->changeInstrumentationCounter(-1); for (size_t i = m_startedProfiles.size(); i > 0; --i) stopProfiling(m_startedProfiles[i - 1].m_id, false); m_startedProfiles.clear(); @@ -205,7 +207,7 @@ void V8ProfilerAgentImpl::setSamplingInterval(ErrorString* error, int interval) *error = "Cannot change sampling interval when profiling."; return; } - m_state->setNumber(ProfilerAgentState::samplingInterval, interval); + m_state->setInteger(ProfilerAgentState::samplingInterval, interval); m_isolate->GetCpuProfiler()->SetSamplingInterval(interval); } @@ -215,9 +217,8 @@ void V8ProfilerAgentImpl::restore() if (!m_state->booleanProperty(ProfilerAgentState::profilerEnabled, false)) return; m_enabled = true; - m_session->changeInstrumentationCounter(+1); int interval = 0; - m_state->getNumber(ProfilerAgentState::samplingInterval, &interval); + m_state->getInteger(ProfilerAgentState::samplingInterval, &interval); if (interval) m_isolate->GetCpuProfiler()->SetSamplingInterval(interval); if (m_state->booleanProperty(ProfilerAgentState::userInitiatedProfiling, false)) { @@ -262,7 +263,7 @@ void V8ProfilerAgentImpl::stop(ErrorString* errorString, std::unique_ptr V8ProfilerAgentImpl::stopProfili bool V8ProfilerAgentImpl::isRecording() const { - return m_recordingCPUProfile || !m_startedProfiles.isEmpty(); + return m_recordingCPUProfile || !m_startedProfiles.empty(); } } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h similarity index 95% rename from deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h index 7fa5f49b4684e1..03b8f703ae1215 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h @@ -9,6 +9,8 @@ #include "platform/inspector_protocol/String16.h" #include "platform/v8_inspector/protocol/Profiler.h" +#include + namespace v8 { class Isolate; } @@ -50,7 +52,7 @@ class V8ProfilerAgentImpl : public protocol::Profiler::Backend { bool m_enabled; bool m_recordingCPUProfile; class ProfileDescriptor; - protocol::Vector m_startedProfiles; + std::vector m_startedProfiles; String16 m_frontendInitiatedProfileId; }; diff --git a/deps/v8_inspector/platform/v8_inspector/V8Regex.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.cpp similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/V8Regex.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.cpp diff --git a/deps/v8_inspector/platform/v8_inspector/V8Regex.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.h similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/V8Regex.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8Regex.h diff --git a/deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp similarity index 89% rename from deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp index dc45b11875ec86..c9a235ae29e5fd 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp @@ -34,6 +34,7 @@ #include "platform/v8_inspector/InjectedScript.h" #include "platform/v8_inspector/InspectedContext.h" #include "platform/v8_inspector/RemoteObjectId.h" +#include "platform/v8_inspector/V8ConsoleMessage.h" #include "platform/v8_inspector/V8DebuggerImpl.h" #include "platform/v8_inspector/V8InspectorSessionImpl.h" #include "platform/v8_inspector/V8StringUtil.h" @@ -87,11 +88,13 @@ void V8RuntimeAgentImpl::evaluate( if (executionContextId.isJust()) { contextId = executionContextId.fromJust(); } else { - contextId = m_debugger->client()->ensureDefaultContextInGroup(m_session->contextGroupId()); - if (!contextId) { + v8::HandleScope handles(m_debugger->isolate()); + v8::Local defaultContext = m_debugger->client()->ensureDefaultContextInGroup(m_session->contextGroupId()); + if (defaultContext.IsEmpty()) { *errorString = "Cannot find default execution context"; return; } + contextId = V8DebuggerImpl::contextId(defaultContext); } InjectedScript::ContextScope scope(errorString, m_debugger, m_session->contextGroupId(), contextId); @@ -218,7 +221,7 @@ void V8RuntimeAgentImpl::getProperties( if (!errorString->isEmpty() || exceptionDetails->isJust() || accessorPropertiesOnly.fromMaybe(false)) return; v8::Local propertiesArray; - if (hasInternalError(errorString, !v8::Debug::GetInternalProperties(m_debugger->isolate(), scope.object()).ToLocal(&propertiesArray))) + if (hasInternalError(errorString, !m_debugger->internalProperties(scope.context(), scope.object()).ToLocal(&propertiesArray))) return; std::unique_ptr> propertiesProtocolArray = protocol::Array::create(); for (uint32_t i = 0; i < propertiesArray->Length(); i += 2) { @@ -264,6 +267,12 @@ void V8RuntimeAgentImpl::setCustomObjectFormatterEnabled(ErrorString*, bool enab m_session->setCustomObjectFormatterEnabled(enabled); } +void V8RuntimeAgentImpl::discardConsoleEntries(ErrorString*) +{ + V8ConsoleMessageStorage* storage = m_session->debugger()->ensureConsoleMessageStorage(m_session->contextGroupId()); + storage->clear(); +} + void V8RuntimeAgentImpl::compileScript(ErrorString* errorString, const String16& expression, const String16& sourceURL, @@ -293,9 +302,9 @@ void V8RuntimeAgentImpl::compileScript(ErrorString* errorString, if (!persistScript) return; - String16 scriptValueId = String16::number(script->GetUnboundScript()->GetId()); + String16 scriptValueId = String16::fromInteger(script->GetUnboundScript()->GetId()); std::unique_ptr> global(new v8::Global(m_debugger->isolate(), script)); - m_compiledScripts.set(scriptValueId, std::move(global)); + m_compiledScripts[scriptValueId] = std::move(global); *scriptId = scriptValueId; } @@ -313,7 +322,8 @@ void V8RuntimeAgentImpl::runScript(ErrorString* errorString, return; } - if (!m_compiledScripts.contains(scriptId)) { + auto it = m_compiledScripts.find(scriptId); + if (it == m_compiledScripts.end()) { *errorString = "Script execution failed"; return; } @@ -325,7 +335,8 @@ void V8RuntimeAgentImpl::runScript(ErrorString* errorString, if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false)) scope.ignoreExceptionsAndMuteConsole(); - std::unique_ptr> scriptWrapper = m_compiledScripts.take(scriptId); + std::unique_ptr> scriptWrapper = std::move(it->second); + m_compiledScripts.erase(it); v8::Local script = scriptWrapper->Get(m_debugger->isolate()); if (script.IsEmpty()) { *errorString = "Script execution failed"; @@ -358,11 +369,14 @@ void V8RuntimeAgentImpl::enable(ErrorString* errorString) { if (m_enabled) return; - m_session->changeInstrumentationCounter(+1); + m_session->client()->runtimeEnabled(); m_enabled = true; m_state->setBoolean(V8RuntimeAgentImplState::runtimeEnabled, true); - v8::HandleScope handles(m_debugger->isolate()); + m_session->debugger()->enableStackCapturingIfNeeded(); m_session->reportAllContexts(this); + V8ConsoleMessageStorage* storage = m_session->debugger()->ensureConsoleMessageStorage(m_session->contextGroupId()); + for (const auto& message : storage->messages()) + reportMessage(message.get(), false); } void V8RuntimeAgentImpl::disable(ErrorString* errorString) @@ -371,9 +385,10 @@ void V8RuntimeAgentImpl::disable(ErrorString* errorString) return; m_enabled = false; m_state->setBoolean(V8RuntimeAgentImplState::runtimeEnabled, false); + m_session->debugger()->disableStackCapturingIfNeeded(); m_session->discardInjectedScripts(); reset(); - m_session->changeInstrumentationCounter(-1); + m_session->client()->runtimeDisabled(); } void V8RuntimeAgentImpl::reset() @@ -416,4 +431,16 @@ void V8RuntimeAgentImpl::inspect(std::unique_ptrreportToFrontend(&m_frontend, m_session, generatePreview); + m_frontend.flush(); +} + } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h similarity index 95% rename from deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h index 7eb2b135450c4c..7b33379a0c29c0 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h @@ -42,6 +42,7 @@ namespace blink { class InjectedScript; class InspectedContext; class RemoteObjectIdBase; +class V8ConsoleMessage; class V8DebuggerImpl; class V8InspectorSessionImpl; @@ -95,6 +96,7 @@ class V8RuntimeAgentImpl : public protocol::Runtime::Backend { void releaseObjectGroup(ErrorString*, const String16& objectGroup) override; void run(ErrorString*) override; void setCustomObjectFormatterEnabled(ErrorString*, bool) override; + void discardConsoleEntries(ErrorString*) override; void compileScript(ErrorString*, const String16& expression, const String16& sourceURL, @@ -115,8 +117,12 @@ class V8RuntimeAgentImpl : public protocol::Runtime::Backend { void reportExecutionContextCreated(InspectedContext*); void reportExecutionContextDestroyed(InspectedContext*); void inspect(std::unique_ptr objectToInspect, std::unique_ptr hints); + void messageAdded(V8ConsoleMessage*); + bool enabled() const { return m_enabled; } private: + void reportMessage(V8ConsoleMessage*, bool generatePreview); + V8InspectorSessionImpl* m_session; protocol::DictionaryValue* m_state; protocol::Runtime::Frontend m_frontend; diff --git a/deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp similarity index 70% rename from deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp index 650c71eb957f20..343234c02278cc 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp @@ -6,7 +6,6 @@ #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" -#include "platform/v8_inspector/V8DebuggerAgentImpl.h" #include "platform/v8_inspector/V8DebuggerImpl.h" #include "platform/v8_inspector/V8StringUtil.h" @@ -18,9 +17,16 @@ namespace blink { namespace { +static const v8::StackTrace::StackTraceOptions stackTraceOptions = static_cast( + v8::StackTrace::kLineNumber | + v8::StackTrace::kColumnOffset | + v8::StackTrace::kScriptId | + v8::StackTrace::kScriptNameOrSourceURL | + v8::StackTrace::kFunctionName); + V8StackTraceImpl::Frame toFrame(v8::Local frame) { - String16 scriptId = String16::number(frame->GetScriptId()); + String16 scriptId = String16::fromInteger(frame->GetScriptId()); String16 sourceName; v8::Local sourceNameValue(frame->GetScriptNameOrSourceURL()); if (!sourceNameValue.IsEmpty()) @@ -36,7 +42,7 @@ V8StackTraceImpl::Frame toFrame(v8::Local frame) return V8StackTraceImpl::Frame(functionName, scriptId, sourceName, sourceLineNumber, sourceColumn); } -void toFramesVector(v8::Local stackTrace, protocol::Vector& frames, size_t maxStackSize, v8::Isolate* isolate) +void toFramesVector(v8::Local stackTrace, std::vector& frames, size_t maxStackSize, v8::Isolate* isolate) { DCHECK(isolate->InContext()); int frameCount = stackTrace->GetFrameCount(); @@ -44,7 +50,7 @@ void toFramesVector(v8::Local stackTrace, protocol::Vector stackFrame = stackTrace->GetFrame(i); - frames.append(toFrame(stackFrame)); + frames.push_back(toFrame(stackFrame)); } } @@ -66,6 +72,8 @@ V8StackTraceImpl::Frame::Frame(const String16& functionName, const String16& scr , m_lineNumber(lineNumber) , m_columnNumber(column) { + DCHECK(m_lineNumber != v8::Message::kNoLineNumberInfo); + DCHECK(m_columnNumber != v8::Message::kNoColumnInfo); } V8StackTraceImpl::Frame::~Frame() @@ -80,8 +88,8 @@ std::unique_ptr V8StackTraceImpl::Frame::buildInsp .setFunctionName(m_functionName) .setScriptId(m_scriptId) .setUrl(m_scriptName) - .setLineNumber(m_lineNumber) - .setColumnNumber(m_columnNumber) + .setLineNumber(m_lineNumber - 1) + .setColumnNumber(m_columnNumber - 1) .build(); } @@ -90,19 +98,32 @@ V8StackTraceImpl::Frame V8StackTraceImpl::Frame::isolatedCopy() const return Frame(m_functionName.isolatedCopy(), m_scriptId.isolatedCopy(), m_scriptName.isolatedCopy(), m_lineNumber, m_columnNumber); } -std::unique_ptr V8StackTraceImpl::create(V8DebuggerAgentImpl* agent, v8::Local stackTrace, size_t maxStackSize, const String16& description) +// static +void V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions(v8::Isolate* isolate, bool capture) +{ + isolate->SetCaptureStackTraceForUncaughtExceptions(capture, V8StackTraceImpl::maxCallStackSizeToCapture, stackTraceOptions); +} + +// static +std::unique_ptr V8StackTraceImpl::create(V8DebuggerImpl* debugger, int contextGroupId, v8::Local stackTrace, size_t maxStackSize, const String16& description) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope scope(isolate); - protocol::Vector frames; + std::vector frames; if (!stackTrace.IsEmpty()) toFramesVector(stackTrace, frames, maxStackSize, isolate); int maxAsyncCallChainDepth = 1; V8StackTraceImpl* asyncCallChain = nullptr; - if (agent && maxStackSize > 1) { - asyncCallChain = agent->currentAsyncCallChain(); - maxAsyncCallChainDepth = agent->maxAsyncCallChainDepth(); + if (debugger && maxStackSize > 1) { + asyncCallChain = debugger->currentAsyncCallChain(); + maxAsyncCallChainDepth = debugger->maxAsyncCallChainDepth(); + } + // Do not accidentally append async call chain from another group. This should not + // happen if we have proper instrumentation, but let's double-check to be safe. + if (contextGroupId && asyncCallChain && asyncCallChain->m_contextGroupId && asyncCallChain->m_contextGroupId != contextGroupId) { + asyncCallChain = nullptr; + maxAsyncCallChainDepth = 1; } // Only the top stack in the chain may be empty, so ensure that second stack is non-empty (it's the top of appended chain). @@ -112,7 +133,7 @@ std::unique_ptr V8StackTraceImpl::create(V8DebuggerAgentImpl* if (stackTrace.IsEmpty() && !asyncCallChain) return nullptr; - std::unique_ptr result(new V8StackTraceImpl(description, frames, asyncCallChain ? asyncCallChain->cloneImpl() : nullptr)); + std::unique_ptr result(new V8StackTraceImpl(contextGroupId, description, frames, asyncCallChain ? asyncCallChain->cloneImpl() : nullptr)); // Crop to not exceed maxAsyncCallChainDepth. V8StackTraceImpl* deepest = result.get(); @@ -126,7 +147,7 @@ std::unique_ptr V8StackTraceImpl::create(V8DebuggerAgentImpl* return result; } -std::unique_ptr V8StackTraceImpl::capture(V8DebuggerAgentImpl* agent, size_t maxStackSize, const String16& description) +std::unique_ptr V8StackTraceImpl::capture(V8DebuggerImpl* debugger, int contextGroupId, size_t maxStackSize, const String16& description) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope handleScope(isolate); @@ -137,7 +158,7 @@ std::unique_ptr V8StackTraceImpl::capture(V8DebuggerAgentImpl* #endif stackTrace = v8::StackTrace::CurrentStackTrace(isolate, maxStackSize, stackTraceOptions); } - return V8StackTraceImpl::create(agent, stackTrace, maxStackSize, description); + return V8StackTraceImpl::create(debugger, contextGroupId, stackTrace, maxStackSize, description); } std::unique_ptr V8StackTraceImpl::clone() @@ -147,8 +168,8 @@ std::unique_ptr V8StackTraceImpl::clone() std::unique_ptr V8StackTraceImpl::cloneImpl() { - protocol::Vector framesCopy(m_frames); - return wrapUnique(new V8StackTraceImpl(m_description, framesCopy, m_parent ? m_parent->cloneImpl() : nullptr)); + std::vector framesCopy(m_frames); + return wrapUnique(new V8StackTraceImpl(m_contextGroupId, m_description, framesCopy, m_parent ? m_parent->cloneImpl() : nullptr)); } std::unique_ptr V8StackTraceImpl::isolatedCopy() @@ -158,14 +179,15 @@ std::unique_ptr V8StackTraceImpl::isolatedCopy() std::unique_ptr V8StackTraceImpl::isolatedCopyImpl() { - protocol::Vector frames; + std::vector frames; for (size_t i = 0; i < m_frames.size(); i++) - frames.append(m_frames.at(i).isolatedCopy()); - return wrapUnique(new V8StackTraceImpl(m_description.isolatedCopy(), frames, m_parent ? m_parent->isolatedCopyImpl() : nullptr)); + frames.push_back(m_frames.at(i).isolatedCopy()); + return wrapUnique(new V8StackTraceImpl(m_contextGroupId, m_description.isolatedCopy(), frames, m_parent ? m_parent->isolatedCopyImpl() : nullptr)); } -V8StackTraceImpl::V8StackTraceImpl(const String16& description, protocol::Vector& frames, std::unique_ptr parent) - : m_description(description) +V8StackTraceImpl::V8StackTraceImpl(int contextGroupId, const String16& description, std::vector& frames, std::unique_ptr parent) + : m_contextGroupId(contextGroupId) + , m_description(description) , m_parent(std::move(parent)) { m_frames.swap(frames); @@ -220,11 +242,11 @@ std::unique_ptr V8StackTraceImpl::buildInspectorO return stackTrace; } -std::unique_ptr V8StackTraceImpl::buildInspectorObjectForTail(V8DebuggerAgentImpl* agent) const +std::unique_ptr V8StackTraceImpl::buildInspectorObjectForTail(V8DebuggerImpl* debugger) const { v8::HandleScope handleScope(v8::Isolate::GetCurrent()); // Next call collapses possible empty stack and ensures maxAsyncCallChainDepth. - std::unique_ptr fullChain = V8StackTraceImpl::create(agent, v8::Local(), V8StackTrace::maxCallStackSizeToCapture); + std::unique_ptr fullChain = V8StackTraceImpl::create(debugger, m_contextGroupId, v8::Local(), V8StackTraceImpl::maxCallStackSizeToCapture); if (!fullChain || !fullChain->m_parent) return nullptr; return fullChain->m_parent->buildInspectorObject(); diff --git a/deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h similarity index 76% rename from deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h index 721789319bb297..63b59e8d9009b3 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h @@ -5,14 +5,15 @@ #ifndef V8StackTraceImpl_h #define V8StackTraceImpl_h -#include "platform/inspector_protocol/Collections.h" #include "platform/inspector_protocol/Platform.h" #include "platform/v8_inspector/public/V8StackTrace.h" +#include + namespace blink { class TracedValue; -class V8DebuggerAgentImpl; +class V8DebuggerImpl; // Note: async stack trace may have empty top stack with non-empty tail to indicate // that current native-only state had some async story. @@ -20,6 +21,8 @@ class V8DebuggerAgentImpl; class V8StackTraceImpl final : public V8StackTrace { PROTOCOL_DISALLOW_COPY(V8StackTraceImpl); public: + static const size_t maxCallStackSizeToCapture = 200; + class Frame { public: Frame(); @@ -45,14 +48,15 @@ class V8StackTraceImpl final : public V8StackTrace { int m_columnNumber; }; - static std::unique_ptr create(V8DebuggerAgentImpl*, v8::Local, size_t maxStackSize, const String16& description = String16()); - static std::unique_ptr capture(V8DebuggerAgentImpl*, size_t maxStackSize, const String16& description = String16()); + static void setCaptureStackTraceForUncaughtExceptions(v8::Isolate*, bool capture); + static std::unique_ptr create(V8DebuggerImpl*, int contextGroupId, v8::Local, size_t maxStackSize, const String16& description = String16()); + static std::unique_ptr capture(V8DebuggerImpl*, int contextGroupId, size_t maxStackSize, const String16& description = String16()); std::unique_ptr clone() override; std::unique_ptr cloneImpl(); std::unique_ptr isolatedCopy() override; std::unique_ptr isolatedCopyImpl(); - std::unique_ptr buildInspectorObjectForTail(V8DebuggerAgentImpl*) const; + std::unique_ptr buildInspectorObjectForTail(V8DebuggerImpl*) const; ~V8StackTraceImpl() override; // V8StackTrace implementation. @@ -66,10 +70,11 @@ class V8StackTraceImpl final : public V8StackTrace { String16 toString() const override; private: - V8StackTraceImpl(const String16& description, protocol::Vector& frames, std::unique_ptr parent); + V8StackTraceImpl(int contextGroupId, const String16& description, std::vector& frames, std::unique_ptr parent); + int m_contextGroupId; String16 m_description; - protocol::Vector m_frames; + std::vector m_frames; std::unique_ptr m_parent; }; diff --git a/deps/v8_inspector/platform/v8_inspector/V8StringUtil.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.cpp similarity index 90% rename from deps/v8_inspector/platform/v8_inspector/V8StringUtil.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.cpp index e47981e72ccc97..4ba7898bc58162 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8StringUtil.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.cpp @@ -9,7 +9,6 @@ #include "platform/v8_inspector/V8InspectorSessionImpl.h" #include "platform/v8_inspector/V8Regex.h" #include "platform/v8_inspector/public/V8ContentSearchUtil.h" -#include "platform/v8_inspector/public/V8ToProtocolValue.h" namespace blink { @@ -95,9 +94,9 @@ String16 createSearchRegexSource(const String16& text) return result.toString(); } -std::unique_ptr> lineEndings(const String16& text) +std::unique_ptr> lineEndings(const String16& text) { - std::unique_ptr> result(new protocol::Vector()); + std::unique_ptr> result(new std::vector()); unsigned start = 0; while (start < text.length()) { @@ -105,21 +104,21 @@ std::unique_ptr> lineEndings(const String16& text) if (lineEnd == kNotFound) break; - result->append(static_cast(lineEnd)); + result->push_back(static_cast(lineEnd)); start = lineEnd + 1; } - result->append(text.length()); + result->push_back(text.length()); return result; } -protocol::Vector> scriptRegexpMatchesByLines(const V8Regex& regex, const String16& text) +std::vector> scriptRegexpMatchesByLines(const V8Regex& regex, const String16& text) { - protocol::Vector> result; + std::vector> result; if (text.isEmpty()) return result; - std::unique_ptr> endings(lineEndings(text)); + std::unique_ptr> endings(lineEndings(text)); unsigned size = endings->size(); unsigned start = 0; for (unsigned lineNumber = 0; lineNumber < size; ++lineNumber) { @@ -130,7 +129,7 @@ protocol::Vector> scriptRegexpMatchesByLines(const V8Re int matchLength; if (regex.match(line, 0, &matchLength) != -1) - result.append(std::pair(lineNumber, line)); + result.push_back(std::pair(lineNumber, line)); start = lineEnd + 1; } @@ -199,7 +198,7 @@ std::unique_ptr> searchInTextBy { std::unique_ptr> result = protocol::Array::create(); std::unique_ptr regex = createSearchRegex(static_cast(session)->debugger(), query, caseSensitive, isRegex); - protocol::Vector> matches = scriptRegexpMatchesByLines(*regex.get(), text); + std::vector> matches = scriptRegexpMatchesByLines(*regex.get(), text); for (const auto& match : matches) result->addItem(buildObjectForSearchMatch(match.first, match.second)); @@ -224,8 +223,13 @@ std::unique_ptr toProtocolValue(v8::Local context, return protocol::Value::null(); if (value->IsBoolean()) return protocol::FundamentalValue::create(value.As()->Value()); - if (value->IsNumber()) - return protocol::FundamentalValue::create(value.As()->Value()); + if (value->IsNumber()) { + double doubleValue = value.As()->Value(); + int intValue = static_cast(doubleValue); + if (intValue == doubleValue) + return protocol::FundamentalValue::create(intValue); + return protocol::FundamentalValue::create(doubleValue); + } if (value->IsString()) return protocol::StringValue::create(toProtocolString(value.As())); if (value->IsArray()) { diff --git a/deps/v8_inspector/platform/v8_inspector/V8StringUtil.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.h similarity index 76% rename from deps/v8_inspector/platform/v8_inspector/V8StringUtil.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.h index c1c506baae8140..2d42613d41614d 100644 --- a/deps/v8_inspector/platform/v8_inspector/V8StringUtil.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/V8StringUtil.h @@ -6,10 +6,13 @@ #define V8StringUtil_h #include "platform/inspector_protocol/String16.h" +#include "platform/inspector_protocol/Values.h" #include namespace blink { +std::unique_ptr toProtocolValue(v8::Local, v8::Local, int maxDepth = protocol::Value::maxDepth); + v8::Local toV8String(v8::Isolate*, const String16&); v8::Local toV8StringInternalized(v8::Isolate*, const String16&); diff --git a/deps/v8_inspector/platform/v8_inspector/build/rjsmin.py b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/build/rjsmin.py similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/build/rjsmin.py rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/build/rjsmin.py diff --git a/deps/v8_inspector/platform/v8_inspector/build/xxd.py b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/build/xxd.py similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/build/xxd.py rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/build/xxd.py diff --git a/deps/v8_inspector/platform/v8_inspector/debugger_script_externs.js b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/debugger_script_externs.js similarity index 98% rename from deps/v8_inspector/platform/v8_inspector/debugger_script_externs.js rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/debugger_script_externs.js index 25d07542792e92..cf2a0457c4c1b3 100644 --- a/deps/v8_inspector/platform/v8_inspector/debugger_script_externs.js +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/debugger_script_externs.js @@ -18,14 +18,6 @@ var Scope; }} */ var RawLocation; -/** @typedef {{ - function: function(), - functionName: string, - status: string, - location: (!RawLocation|undefined) - }} */ -var GeneratorObjectDetails; - /** @typedef {{ id: number, name: string, diff --git a/deps/v8_inspector/platform/v8_inspector/injected_script_externs.js b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/injected_script_externs.js similarity index 92% rename from deps/v8_inspector/platform/v8_inspector/injected_script_externs.js rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/injected_script_externs.js index 218010938c10e3..5fba025caab2b8 100644 --- a/deps/v8_inspector/platform/v8_inspector/injected_script_externs.js +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/injected_script_externs.js @@ -32,12 +32,6 @@ InjectedScriptHostClass.prototype.subtype = function(obj) {} */ InjectedScriptHostClass.prototype.isTypedArray = function(obj) {} -/** - * @param {!Object} obj - * @return {?Array.<*>} - */ -InjectedScriptHostClass.prototype.collectionEntries = function(obj) {} - /** * @param {*} obj * @return {!Array.<*>} diff --git a/deps/v8_inspector/platform/v8_inspector/js_protocol-1.1.json b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/js_protocol-1.1.json similarity index 100% rename from deps/v8_inspector/platform/v8_inspector/js_protocol-1.1.json rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/js_protocol-1.1.json diff --git a/deps/v8_inspector/platform/v8_inspector/js_protocol.json b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/js_protocol.json similarity index 90% rename from deps/v8_inspector/platform/v8_inspector/js_protocol.json rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/js_protocol.json index 9ae7e60cb025ac..78548bc8402aeb 100644 --- a/deps/v8_inspector/platform/v8_inspector/js_protocol.json +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/js_protocol.json @@ -133,16 +133,23 @@ { "id": "ExceptionDetails", "type": "object", - "description": "Detailed information on exception (or error) that was thrown during script compilation or execution.", + "hidden": true, + "description": "Detailed information about exception (or error) that was thrown during script compilation or execution.", "properties": [ { "name": "text", "type": "string", "description": "Exception text." }, - { "name": "url", "type": "string", "optional": true, "description": "URL of the message origin." }, - { "name": "scriptId", "type": "string", "optional": true, "description": "Script ID of the message origin." }, - { "name": "line", "type": "integer", "optional": true, "description": "Line number in the resource that generated this message." }, - { "name": "column", "type": "integer", "optional": true, "description": "Column number in the resource that generated this message." }, - { "name": "stack", "$ref": "StackTrace", "optional": true, "description": "JavaScript stack trace for assertions and error messages." } + { "name": "scriptId", "$ref": "ScriptId", "description": "Script ID of the exception location." }, + { "name": "lineNumber", "type": "integer", "description": "Line number of the exception location (0-based)." }, + { "name": "columnNumber", "type": "integer", "description": "Column number of the exception location (0-based)." }, + { "name": "url", "type": "string", "optional": true, "description": "URL of the exception location, to be used when the script was not reported." }, + { "name": "stackTrace", "$ref": "StackTrace", "optional": true, "description": "JavaScript stack trace if available." } ] }, + { + "id": "Timestamp", + "type": "number", + "description": "Number of milliseconds since epoch.", + "hidden": true + }, { "id": "CallFrame", "type": "object", @@ -151,8 +158,8 @@ { "name": "functionName", "type": "string", "description": "JavaScript function name." }, { "name": "scriptId", "$ref": "ScriptId", "description": "JavaScript script id." }, { "name": "url", "type": "string", "description": "JavaScript script name or url." }, - { "name": "lineNumber", "type": "integer", "description": "JavaScript script line number." }, - { "name": "columnNumber", "type": "integer", "description": "JavaScript script column number." } + { "name": "lineNumber", "type": "integer", "description": "JavaScript script line number (0-based)." }, + { "name": "columnNumber", "type": "integer", "description": "JavaScript script column number (0-based)." } ] }, { @@ -162,7 +169,7 @@ "properties": [ { "name": "description", "type": "string", "optional": true, "description": "String label of this stack trace. For async traces this may be a name of the function that initiated the async call." }, { "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "JavaScript function name." }, - { "name": "parent", "$ref": "StackTrace", "optional": true, "hidden": true, "hidden": true, "description": "Asynchronous JavaScript stack trace that preceded this stack, if available." } + { "name": "parent", "$ref": "StackTrace", "optional": true, "hidden": true, "description": "Asynchronous JavaScript stack trace that preceded this stack, if available." } ] } ], @@ -246,6 +253,11 @@ "hidden": true, "description": "Disables reporting of execution contexts creation." }, + { + "name": "discardConsoleEntries", + "hidden": true, + "description": "Discards collected exceptions and console API calls." + }, { "name": "setCustomObjectFormatterEnabled", "parameters": [ @@ -307,6 +319,39 @@ "name": "executionContextsCleared", "description": "Issued when all executionContexts were cleared in browser" }, + { + "name": "exceptionThrown", + "description": "Issued when exception was thrown and unhandled.", + "parameters": [ + { "name": "exceptionId", "type": "integer", "description": "Exception id." }, + { "name": "timestamp", "$ref": "Timestamp", "description": "Timestamp of the exception." }, + { "name": "details", "$ref": "ExceptionDetails" }, + { "name": "exception", "$ref": "RemoteObject", "optional": true, "description": "Exception object." }, + { "name": "executionContextId", "$ref": "ExecutionContextId", "optional": true, "description": "Identifier of the context where exception happened." } + ], + "hidden": true + }, + { + "name": "exceptionRevoked", + "description": "Issued when unhandled exception was revoked.", + "parameters": [ + { "name": "message", "type": "string", "description": "Message describing why exception was revoked." }, + { "name": "exceptionId", "type": "integer", "description": "The id of revoked exception, as reported in exceptionUnhandled." } + ], + "hidden": true + }, + { + "name": "consoleAPICalled", + "description": "Issued when console API was called.", + "parameters": [ + { "name": "type", "type": "string", "enum": ["log", "debug", "info", "error", "warning", "dir", "dirxml", "table", "trace", "clear", "startGroup", "startGroupCollapsed", "endGroup", "assert", "profile", "profileEnd"], "description": "Type of the call." }, + { "name": "args", "type": "array", "items": { "$ref": "RemoteObject" }, "description": "Call arguments." }, + { "name": "executionContextId", "$ref": "ExecutionContextId", "description": "Identifier of the context where the call was made." }, + { "name": "timestamp", "$ref": "Timestamp", "description": "Call timestamp." }, + { "name": "stackTrace", "$ref": "StackTrace", "optional": true, "description": "Stack trace captured when the call was made." } + ], + "hidden": true + }, { "name": "inspectRequested", "parameters": [ @@ -347,45 +392,11 @@ "hidden": true, "type": "object", "properties": [ - { "name": "line", "type": "integer" }, - { "name": "column", "type": "integer" } + { "name": "lineNumber", "type": "integer" }, + { "name": "columnNumber", "type": "integer" } ], "description": "Location in the source code." }, - { - "id": "FunctionDetails", - "hidden": true, - "type": "object", - "properties": [ - { "name": "location", "$ref": "Location", "optional": true, "description": "Location of the function, none for native functions." }, - { "name": "functionName", "type": "string", "description": "Name of the function." }, - { "name": "isGenerator", "type": "boolean", "description": "Whether this is a generator function." }, - { "name": "scopeChain", "type": "array", "optional": true, "items": { "$ref": "Scope" }, "description": "Scope chain for this closure." } - ], - "description": "Information about the function." - }, - { - "id": "GeneratorObjectDetails", - "hidden": true, - "type": "object", - "properties": [ - { "name": "function", "$ref": "Runtime.RemoteObject", "description": "Generator function." }, - { "name": "functionName", "type": "string", "description": "Name of the generator function." }, - { "name": "status", "type": "string", "enum": ["running", "suspended", "closed"], "description": "Current generator object status." }, - { "name": "location", "$ref": "Location", "optional": true, "description": "If suspended, location where generator function was suspended (e.g. location of the last 'yield'). Otherwise, location of the generator function." } - ], - "description": "Information about the generator object." - }, - { - "id": "CollectionEntry", - "hidden": true, - "type": "object", - "properties": [ - { "name": "key", "$ref": "Runtime.RemoteObject", "optional": true, "description": "Entry key of a map-like collection, otherwise not provided." }, - { "name": "value", "$ref": "Runtime.RemoteObject", "description": "Entry value." } - ], - "description": "Collection entry." - }, { "id": "CallFrame", "type": "object", @@ -412,17 +423,6 @@ ], "description": "Scope description." }, - { - "id": "SetScriptSourceError", - "type": "object", - "properties": [ - { "name": "message", "type": "string", "description": "Compiler error message" }, - { "name": "lineNumber", "type": "integer", "description": "Compile error line number (1-based)" }, - { "name": "columnNumber", "type": "integer", "description": "Compile error column number (1-based)" } - ], - "description": "Error data for setScriptSource command. Contains uncompilable script source error.", - "hidden": true - }, { "id": "SearchMatch", "type": "object", @@ -551,7 +551,7 @@ { "name": "callFrames", "type": "array", "optional": true, "items": { "$ref": "CallFrame" }, "description": "New stack trace in case editing has happened while VM was stopped." }, { "name": "stackChanged", "type": "boolean", "optional": true, "description": "Whether current call stack was modified after applying the changes.", "hidden": true }, { "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any.", "hidden": true }, - { "name": "compileError", "optional": true, "$ref": "SetScriptSourceError", "description": "Error data if any." } + { "name": "compileError", "optional": true, "$ref": "Runtime.ExceptionDetails", "description": "Error data if any." } ], "description": "Edits JavaScript source live." }, @@ -577,39 +577,6 @@ ], "description": "Returns source for the script with given id." }, - { - "name": "getFunctionDetails", - "hidden": true, - "parameters": [ - { "name": "functionId", "$ref": "Runtime.RemoteObjectId", "description": "Id of the function to get details for." } - ], - "returns": [ - { "name": "details", "$ref": "FunctionDetails", "description": "Information about the function." } - ], - "description": "Returns detailed information on given function." - }, - { - "name": "getGeneratorObjectDetails", - "hidden": true, - "parameters": [ - { "name": "objectId", "$ref": "Runtime.RemoteObjectId", "description": "Id of the generator object to get details for." } - ], - "returns": [ - { "name": "details", "$ref": "GeneratorObjectDetails", "description": "Information about the generator object." } - ], - "description": "Returns detailed information on given generator object." - }, - { - "name": "getCollectionEntries", - "hidden": true, - "parameters": [ - { "name": "objectId", "$ref": "Runtime.RemoteObjectId", "description": "Id of the collection to get entries for." } - ], - "returns": [ - { "name": "entries", "type": "array", "items": { "$ref": "CollectionEntry" }, "description": "Array of collection entries." } - ], - "description": "Returns entries of given collection." - }, { "name": "setPauseOnExceptions", "parameters": [ @@ -733,7 +700,7 @@ "name": "paused", "parameters": [ { "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "Call stack the virtual machine stopped on." }, - { "name": "reason", "type": "string", "enum": [ "XHR", "DOM", "EventListener", "exception", "assert", "CSPViolation", "debugCommand", "promiseRejection", "other" ], "description": "Pause reason." }, + { "name": "reason", "type": "string", "enum": [ "XHR", "DOM", "EventListener", "exception", "assert", "debugCommand", "promiseRejection", "other" ], "description": "Pause reason." }, { "name": "data", "type": "object", "optional": true, "description": "Object containing break-specific auxiliary properties." }, { "name": "hitBreakpoints", "type": "array", "optional": true, "items": { "type": "string" }, "description": "Hit breakpoints IDs", "hidden": true }, { "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any.", "hidden": true } @@ -746,6 +713,64 @@ } ] }, + { + "domain": "Console", + "description": "This domain is deprecated - use Runtime or Log instead.", + "dependencies": ["Runtime"], + "deprecated": true, + "types": [ + { + "id": "ConsoleMessage", + "type": "object", + "description": "Console message.", + "properties": [ + { "name": "source", "type": "string", "enum": ["xml", "javascript", "network", "console-api", "storage", "appcache", "rendering", "security", "other", "deprecation", "worker"], "description": "Message source." }, + { "name": "level", "type": "string", "enum": ["log", "warning", "error", "debug", "info"], "description": "Message severity." }, + { "name": "text", "type": "string", "description": "Message text." }, + { "name": "url", "type": "string", "optional": true, "description": "URL of the message origin." }, + { "name": "line", "type": "integer", "optional": true, "description": "Line number in the resource that generated this message (1-based)." }, + { "name": "column", "type": "integer", "optional": true, "description": "Column number in the resource that generated this message (1-based)." } + ] + } + ], + "commands": [ + { + "name": "enable", + "description": "Enables console domain, sends the messages collected so far to the client by means of the messageAdded notification." + }, + { + "name": "disable", + "description": "Disables console domain, prevents further console messages from being reported to the client." + }, + { + "name": "clearMessages", + "description": "Does nothing." + } + ], + "events": [ + { + "name": "messageAdded", + "parameters": [ + { "name": "message", "$ref": "ConsoleMessage", "description": "Console message that has been added." } + ], + "description": "Issued when new console message is added." + }, + { + "name": "messageRepeatCountUpdated", + "parameters": [ + { "name": "count", "type": "integer", "description": "New repeat count value." }, + { "name": "timestamp", "$ref": "Runtime.Timestamp", "description": "Timestamp of most recent message in batch.", "hidden": true } + ], + "description": "Not issued.", + "deprecated": true + }, + { + "name": "messagesCleared", + "description": "Not issued.", + "deprecated": true + } + ] + }, { "domain": "Profiler", "dependencies": ["Runtime", "Debugger"], @@ -756,13 +781,8 @@ "type": "object", "description": "CPU Profile node. Holds callsite information, execution statistics and child nodes.", "properties": [ - { "name": "functionName", "type": "string", "description": "Function name." }, - { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Script identifier." }, - { "name": "url", "type": "string", "description": "URL." }, - { "name": "lineNumber", "type": "integer", "description": "1-based line number of the function start position." }, - { "name": "columnNumber", "type": "integer", "description": "1-based column number of the function start position." }, + { "name": "callFrame", "$ref": "Runtime.CallFrame", "description": "Function location." }, { "name": "hitCount", "type": "integer", "description": "Number of samples where this node was on top of the call stack." }, - { "name": "callUID", "type": "number", "description": "Call UID." }, { "name": "children", "type": "array", "items": { "$ref": "CPUProfileNode" }, "description": "Child nodes." }, { "name": "deoptReason", "type": "string", "description": "The reason of being not optimized. The function may be deoptimized or marked as don't optimize."}, { "name": "id", "type": "integer", "description": "Unique id of the node." }, @@ -822,7 +842,6 @@ { "name": "id", "type": "string" }, { "name": "location", "$ref": "Debugger.Location", "description": "Location of console.profile()." }, { "name": "title", "type": "string", "optional": true, "description": "Profile title passed as argument to console.profile()." } - ], "description": "Sent when new profile recodring is started using console.profile() call." }, @@ -852,11 +871,7 @@ "type": "object", "description": "Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes.", "properties": [ - { "name": "functionName", "type": "string", "description": "Function name." }, - { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Script identifier." }, - { "name": "url", "type": "string", "description": "URL." }, - { "name": "lineNumber", "type": "integer", "description": "1-based line number of the function start position." }, - { "name": "columnNumber", "type": "integer", "description": "1-based column number of the function start position." }, + { "name": "callFrame", "$ref": "Runtime.CallFrame", "description": "Function location." }, { "name": "selfSize", "type": "number", "description": "Allocations size in bytes for the node excluding children." }, { "name": "children", "type": "array", "items": { "$ref": "SamplingHeapProfileNode" }, "description": "Child nodes." } ] @@ -888,7 +903,6 @@ "parameters": [ { "name": "reportProgress", "type": "boolean", "optional": true, "description": "If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken when the tracking is stopped." } ] - }, { "name": "takeHeapSnapshot", diff --git a/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ConsoleTypes.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ConsoleTypes.h new file mode 100644 index 00000000000000..73c1878e9e3d84 --- /dev/null +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ConsoleTypes.h @@ -0,0 +1,20 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8ConsoleTypes_h +#define V8ConsoleTypes_h + +namespace blink { + +enum MessageLevel { + DebugMessageLevel = 4, + LogMessageLevel = 1, + InfoMessageLevel = 5, + WarningMessageLevel = 2, + ErrorMessageLevel = 3 +}; + +} + +#endif // !defined(V8ConsoleTypes_h) diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h similarity index 94% rename from deps/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h index 35cf12331f88c9..a932b7a4664c92 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h @@ -7,6 +7,7 @@ #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" +#include "platform/v8_inspector/protocol/Debugger.h" namespace blink { diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h similarity index 95% rename from deps/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h index 43ce46f9f6a35f..0dc1de29da75e5 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8ContextInfo.h @@ -5,7 +5,6 @@ #ifndef V8ContextInfo_h #define V8ContextInfo_h -#include "platform/inspector_protocol/Collections.h" #include "platform/inspector_protocol/String16.h" #include @@ -33,6 +32,7 @@ class V8ContextInfo { bool isDefault; const String16 origin; const String16 humanReadableName; + // TODO(dgozman): aux data? const String16 frameId; bool hasMemoryOnConsole; }; diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8Debugger.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Debugger.h similarity index 50% rename from deps/v8_inspector/platform/v8_inspector/public/V8Debugger.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Debugger.h index b605d8a15e9fa4..da3dcacf555b15 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8Debugger.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Debugger.h @@ -7,6 +7,7 @@ #include "platform/inspector_protocol/Platform.h" #include "platform/inspector_protocol/String16.h" +#include "platform/v8_inspector/public/V8ConsoleTypes.h" #include @@ -19,7 +20,6 @@ class V8InspectorSessionClient; class V8StackTrace; namespace protocol { -class DictionaryValue; class FrontendChannel; } @@ -28,23 +28,37 @@ class PLATFORM_EXPORT V8Debugger { static std::unique_ptr create(v8::Isolate*, V8DebuggerClient*); virtual ~V8Debugger() { } - // TODO(dgozman): make this non-static? - static int contextId(v8::Local); - + // Contexts instrumentation. virtual void contextCreated(const V8ContextInfo&) = 0; virtual void contextDestroyed(v8::Local) = 0; - // TODO(dgozman): remove this one. virtual void resetContextGroup(int contextGroupId) = 0; + + // Various instrumentation. virtual void willExecuteScript(v8::Local, int scriptId) = 0; virtual void didExecuteScript(v8::Local) = 0; virtual void idleStarted() = 0; virtual void idleFinished() = 0; - virtual std::unique_ptr connect(int contextGroupId, protocol::FrontendChannel*, V8InspectorSessionClient*, const String16* state) = 0; - virtual bool isPaused() = 0; + // Async call stacks instrumentation. + virtual void asyncTaskScheduled(const String16& taskName, void* task, bool recurring) = 0; + virtual void asyncTaskCanceled(void* task) = 0; + virtual void asyncTaskStarted(void* task) = 0; + virtual void asyncTaskFinished(void* task) = 0; + virtual void allAsyncTasksCanceled() = 0; + // Runtime instrumentation. + // TODO(dgozman): can we pass exception object? + virtual void exceptionThrown(int contextGroupId, const String16& errorMessage, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr, int scriptId) = 0; + virtual unsigned promiseRejected(v8::Local, const String16& errorMessage, v8::Local exception, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr, int scriptId) = 0; + virtual void promiseRejectionRevoked(v8::Local, unsigned promiseRejectionId) = 0; + + // TODO(dgozman): can we remove this method? + virtual void logToConsole(v8::Local, v8::Local arg1, v8::Local arg2) = 0; + + // API methods. + virtual std::unique_ptr connect(int contextGroupId, protocol::FrontendChannel*, V8InspectorSessionClient*, const String16* state) = 0; virtual std::unique_ptr createStackTrace(v8::Local) = 0; - virtual std::unique_ptr captureStackTrace(size_t maxStackSize) = 0; + virtual std::unique_ptr captureStackTrace(bool fullStack) = 0; }; } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h similarity index 73% rename from deps/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h index e927d4cc664c81..3747f66707d051 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h @@ -6,23 +6,22 @@ #define V8DebuggerClient_h #include "platform/inspector_protocol/Platform.h" -#include "platform/v8_inspector/public/ConsoleAPITypes.h" -#include "platform/v8_inspector/public/ConsoleTypes.h" +#include "platform/v8_inspector/public/V8ConsoleTypes.h" #include "platform/v8_inspector/public/V8ContextInfo.h" #include namespace blink { +class V8StackTrace; + class PLATFORM_EXPORT V8DebuggerClient { public: virtual ~V8DebuggerClient() { } virtual void runMessageLoopOnPause(int contextGroupId) = 0; virtual void quitMessageLoopOnPause() = 0; - virtual void muteWarningsAndDeprecations() = 0; - virtual void unmuteWarningsAndDeprecations() = 0; - virtual void muteConsole() = 0; - virtual void unmuteConsole() = 0; + virtual void muteWarningsAndDeprecations(int contextGroupId) = 0; + virtual void unmuteWarningsAndDeprecations(int contextGroupId) = 0; virtual void beginUserGesture() = 0; virtual void endUserGesture() = 0; virtual bool callingContextCanAccessContext(v8::Local calling, v8::Local target) = 0; @@ -30,15 +29,17 @@ class PLATFORM_EXPORT V8DebuggerClient { virtual bool formatAccessorsAsProperties(v8::Local) = 0; virtual bool isExecutionAllowed() = 0; virtual double currentTimeMS() = 0; - virtual int ensureDefaultContextInGroup(int contextGroupId) = 0; + virtual v8::Local ensureDefaultContextInGroup(int contextGroupId) = 0; virtual bool isInspectableHeapObject(v8::Local) = 0; + virtual void enableAsyncInstrumentation() = 0; + virtual void disableAsyncInstrumentation() = 0; virtual void installAdditionalCommandLineAPI(v8::Local, v8::Local) = 0; - virtual void reportMessageToConsole(v8::Local, MessageType, MessageLevel, const String16& message, const v8::FunctionCallbackInfo* arguments, unsigned skipArgumentCount) = 0; virtual void consoleTime(const String16& title) = 0; virtual void consoleTimeEnd(const String16& title) = 0; virtual void consoleTimeStamp(const String16& title) = 0; + virtual void consoleAPIMessage(int contextGroupId, MessageLevel, const String16& message, const String16& url, unsigned lineNumber, unsigned columnNumber, V8StackTrace*) = 0; virtual v8::MaybeLocal memoryInfo(v8::Isolate*, v8::Local) = 0; diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp similarity index 89% rename from deps/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp index fadab16d7ebd1e..f118dcacf3ce5a 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp @@ -13,6 +13,7 @@ namespace blink { V8Inspector::V8Inspector(v8::Isolate* isolate, v8::Local context) + : m_context(context) { m_debugger = V8Debugger::create(isolate, this); m_debugger->contextCreated(V8ContextInfo(context, 1, true, "", @@ -55,21 +56,17 @@ void V8Inspector::dispatchMessageFromFrontend(const String16& message) m_session->dispatchProtocolMessage(message); } -int V8Inspector::ensureDefaultContextInGroup(int contextGroupId) +v8::Local V8Inspector::ensureDefaultContextInGroup(int) { - return 1; + return m_context; } -void V8Inspector::muteConsole() -{ -} - -void V8Inspector::unmuteConsole() +bool V8Inspector::isExecutionAllowed() { - + return true; } -bool V8Inspector::isExecutionAllowed() +bool V8Inspector::canExecuteScripts() { return true; } diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8Inspector.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.h similarity index 73% rename from deps/v8_inspector/platform/v8_inspector/public/V8Inspector.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.h index 38bbc88774cf9c..4dbb797d50935f 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8Inspector.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8Inspector.h @@ -38,40 +38,42 @@ class V8Inspector : public V8DebuggerClient, V8InspectorSessionClient { bool callingContextCanAccessContext(v8::Local calling, v8::Local target) override; String16 valueSubtype(v8::Local) override; bool formatAccessorsAsProperties(v8::Local) override; - void muteWarningsAndDeprecations() override { } - void unmuteWarningsAndDeprecations() override { } + void muteWarningsAndDeprecations(int) override { } + void unmuteWarningsAndDeprecations(int) override { } double currentTimeMS() override { return 0; }; - void muteConsole() override; - void unmuteConsole() override; bool isExecutionAllowed() override; - int ensureDefaultContextInGroup(int contextGroupId) override; + v8::Local ensureDefaultContextInGroup(int contextGroupId) override; void beginUserGesture() override { } void endUserGesture() override { } bool isInspectableHeapObject(v8::Local) override { return true; } void consoleTime(const String16& title) override { } void consoleTimeEnd(const String16& title) override { } void consoleTimeStamp(const String16& title) override { } + void consoleAPIMessage(int contextGroupId, MessageLevel, const String16& message, const String16& url, unsigned lineNumber, unsigned columnNumber, V8StackTrace*) override { } v8::MaybeLocal memoryInfo(v8::Isolate*, v8::Local) override { return v8::MaybeLocal(); } - void reportMessageToConsole(v8::Local, MessageType, MessageLevel, const String16& message, const v8::FunctionCallbackInfo* arguments, unsigned skipArgumentCount) override { } void installAdditionalCommandLineAPI(v8::Local, v8::Local) override { } - - // V8InspectorSessionClient - void startInstrumenting() override { } - void stopInstrumenting() override { } - void resumeStartup() override { } - bool canExecuteScripts() override { return true; } - void profilingStarted() override { } - void profilingStopped() override { } + void enableAsyncInstrumentation() override { } + void disableAsyncInstrumentation() override { } void startRepeatingTimer(double, TimerCallback, void* data) override { } void cancelTimer(void* data) override { } + // V8InspectorSessionClient + void runtimeEnabled() override { }; + void runtimeDisabled() override { }; + void resumeStartup() override { }; + bool canExecuteScripts() override; + void profilingStarted() override { }; + void profilingStopped() override { }; + void consoleCleared() override { }; + std::unique_ptr m_debugger; std::unique_ptr m_session; String16 m_state; + v8::Local m_context; }; } diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h similarity index 64% rename from deps/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h index e9ad175afc830b..2103467e44087b 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h @@ -12,15 +12,9 @@ namespace blink { -class V8DebuggerAgent; -class V8HeapProfilerAgent; -class V8InspectorSessionClient; -class V8ProfilerAgent; -class V8RuntimeAgent; - class PLATFORM_EXPORT V8InspectorSession { public: - static const char backtraceObjectGroup[]; + virtual ~V8InspectorSession() { } // Cross-context inspectable values (DOM nodes in different worlds, etc.). class Inspectable { @@ -28,34 +22,25 @@ class PLATFORM_EXPORT V8InspectorSession { virtual v8::Local get(v8::Local) = 0; virtual ~Inspectable() { } }; + virtual void addInspectedObject(std::unique_ptr) = 0; - virtual ~V8InspectorSession() { } - + // Dispatching protocol messages. + // TODO(dgozman): generate this one. static bool isV8ProtocolMethod(const String16& method); virtual void dispatchProtocolMessage(const String16& message) = 0; virtual String16 stateJSON() = 0; - virtual void addInspectedObject(std::unique_ptr) = 0; - // API for the embedder to report native activities. + // Debugger actions. virtual void schedulePauseOnNextStatement(const String16& breakReason, std::unique_ptr data) = 0; virtual void cancelPauseOnNextStatement() = 0; virtual void breakProgram(const String16& breakReason, std::unique_ptr data) = 0; - virtual void breakProgramOnException(const String16& breakReason, std::unique_ptr data) = 0; virtual void setSkipAllPauses(bool) = 0; virtual void resume() = 0; virtual void stepOver() = 0; - // API to report async call stacks. - virtual void asyncTaskScheduled(const String16& taskName, void* task, bool recurring) = 0; - virtual void asyncTaskCanceled(void* task) = 0; - virtual void asyncTaskStarted(void* task) = 0; - virtual void asyncTaskFinished(void* task) = 0; - virtual void allAsyncTasksCanceled() = 0; - - // API to work with remote objects. - virtual std::unique_ptr wrapObject(v8::Local, v8::Local, const String16& groupName, bool generatePreview = false) = 0; - // FIXME: remove when InspectorConsoleAgent moves into V8 inspector. - virtual std::unique_ptr wrapTable(v8::Local, v8::Local table, v8::Local columns) = 0; + // Remote objects. + static const char backtraceObjectGroup[]; + virtual std::unique_ptr wrapObject(v8::Local, v8::Local, const String16& groupName, bool generatePreview) = 0; virtual v8::Local findObject(ErrorString*, const String16& objectId, v8::Local* = nullptr, String16* objectGroup = nullptr) = 0; virtual void releaseObjectGroup(const String16&) = 0; }; diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h similarity index 68% rename from deps/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h index 87772b3cca241e..e9e7c33ea83fd2 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h @@ -5,23 +5,23 @@ #ifndef V8InspectorSessionClient_h #define V8InspectorSessionClient_h -#include "platform/inspector_protocol/FrontendChannel.h" #include "platform/inspector_protocol/Platform.h" #include namespace blink { -class PLATFORM_EXPORT V8InspectorSessionClient -{ +class PLATFORM_EXPORT V8InspectorSessionClient { public: virtual ~V8InspectorSessionClient() { } - virtual void startInstrumenting() = 0; - virtual void stopInstrumenting() = 0; + virtual void runtimeEnabled() = 0; + virtual void runtimeDisabled() = 0; virtual void resumeStartup() = 0; + // TODO(dgozman): this was added to support service worker shadow page. We should not connect at all. virtual bool canExecuteScripts() = 0; virtual void profilingStarted() = 0; virtual void profilingStopped() = 0; + virtual void consoleCleared() = 0; }; } // namespace blink diff --git a/deps/v8_inspector/platform/v8_inspector/public/V8StackTrace.h b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8StackTrace.h similarity index 74% rename from deps/v8_inspector/platform/v8_inspector/public/V8StackTrace.h rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8StackTrace.h index 6d5c4804c4be35..beee1155f6e87f 100644 --- a/deps/v8_inspector/platform/v8_inspector/public/V8StackTrace.h +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/public/V8StackTrace.h @@ -13,19 +13,9 @@ namespace blink { -class TracedValue; - -const v8::StackTrace::StackTraceOptions stackTraceOptions = static_cast( - v8::StackTrace::kLineNumber | - v8::StackTrace::kColumnOffset | - v8::StackTrace::kScriptId | - v8::StackTrace::kScriptNameOrSourceURL | - v8::StackTrace::kFunctionName); - +// TODO(dgozman): migrate to V8SourceLocation. class V8StackTrace { public: - static const size_t maxCallStackSizeToCapture = 200; - virtual bool isEmpty() const = 0; virtual String16 topSourceURL() const = 0; virtual int topLineNumber() const = 0; diff --git a/deps/v8_inspector/platform/v8_inspector/v8_inspector.gyp b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/v8_inspector.gyp similarity index 90% rename from deps/v8_inspector/platform/v8_inspector/v8_inspector.gyp rename to deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/v8_inspector.gyp index a9b31dc1d4a4af..6de6017c6931af 100644 --- a/deps/v8_inspector/platform/v8_inspector/v8_inspector.gyp +++ b/deps/v8_inspector/third_party/v8_inspector/platform/v8_inspector/v8_inspector.gyp @@ -57,8 +57,8 @@ ['debug_devtools=="node"', { # Node build 'jinja_module_files': [ - '../../deps/jinja2/jinja2/__init__.py', - '../../deps/markupsafe/markupsafe/__init__.py', # jinja2 dep + '../../../jinja2/jinja2/__init__.py', + '../../../markupsafe/markupsafe/__init__.py', # jinja2 dep ], }, { 'jinja_module_files': [ @@ -83,6 +83,8 @@ 'js_protocol.json', ], 'outputs': [ + '<(blink_platform_output_dir)/v8_inspector/protocol/Console.cpp', + '<(blink_platform_output_dir)/v8_inspector/protocol/Console.h', '<(blink_platform_output_dir)/v8_inspector/protocol/Debugger.cpp', '<(blink_platform_output_dir)/v8_inspector/protocol/Debugger.h', '<(blink_platform_output_dir)/v8_inspector/protocol/HeapProfiler.cpp', @@ -143,11 +145,13 @@ ], 'include_dirs': [ '../..', - '../../../v8/include', - '../../../v8', + '../../../../../v8/include', + '../../../../../v8', '<(SHARED_INTERMEDIATE_DIR)/blink', ], 'sources': [ + '<(blink_platform_output_dir)/v8_inspector/protocol/Console.cpp', + '<(blink_platform_output_dir)/v8_inspector/protocol/Console.h', '<(blink_platform_output_dir)/v8_inspector/protocol/Debugger.cpp', '<(blink_platform_output_dir)/v8_inspector/protocol/Debugger.h', '<(blink_platform_output_dir)/v8_inspector/protocol/HeapProfiler.cpp', @@ -160,7 +164,6 @@ '../inspector_protocol/Allocator.h', '../inspector_protocol/Array.h', '../inspector_protocol/Collections.h', - '../inspector_protocol/CollectionsSTL.h', '../inspector_protocol/DispatcherBase.cpp', '../inspector_protocol/DispatcherBase.h', '../inspector_protocol/ErrorSupport.cpp', @@ -193,6 +196,10 @@ 'RemoteObjectId.h', 'V8Console.cpp', 'V8Console.h', + 'V8ConsoleAgentImpl.cpp', + 'V8ConsoleAgentImpl.h', + 'V8ConsoleMessage.cpp', + 'V8ConsoleMessage.h', 'V8DebuggerAgentImpl.cpp', 'V8DebuggerAgentImpl.h', 'V8DebuggerImpl.cpp', @@ -207,6 +214,8 @@ 'V8InjectedScriptHost.h', 'V8InspectorSessionImpl.cpp', 'V8InspectorSessionImpl.h', + 'V8InternalValueType.cpp', + 'V8InternalValueType.h', 'V8ProfilerAgentImpl.cpp', 'V8ProfilerAgentImpl.h', 'V8Regex.cpp', @@ -227,10 +236,9 @@ 'public/V8Inspector.h', 'public/V8InspectorSession.h', 'public/V8StackTrace.h', - 'public/V8ToProtocolValue.h', - '<(blink_platform_output_dir/v8_inspector/DebuggerScript.h', - '<(blink_platform_output_dir/v8_inspector/InjectedScriptSource.h', + '<(blink_platform_output_dir)/v8_inspector/DebuggerScript.h', + '<(blink_platform_output_dir)/v8_inspector/InjectedScriptSource.h', ], }, ], # targets diff --git a/node.gyp b/node.gyp index e8b957267e9710..cd6a37f28e7190 100644 --- a/node.gyp +++ b/node.gyp @@ -308,6 +308,7 @@ 'defines': [ 'HAVE_INSPECTOR=1', 'V8_INSPECTOR_USE_STL=1', + 'V8_INSPECTOR_USE_OLD_STL=1', ], 'sources': [ 'src/inspector_agent.cc', @@ -316,11 +317,11 @@ 'src/inspector-agent.h', ], 'dependencies': [ - 'deps/v8_inspector/platform/v8_inspector/v8_inspector.gyp:v8_inspector_stl', + 'deps/v8_inspector/third_party/v8_inspector/platform/' + 'v8_inspector/v8_inspector.gyp:v8_inspector_stl', ], 'include_dirs': [ - 'deps/v8_inspector', - 'deps/v8_inspector/deps/wtf', # temporary + 'deps/v8_inspector/third_party/v8_inspector', '<(SHARED_INTERMEDIATE_DIR)/blink', # for inspector ], }, { diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index d8233f41dc2de9..66928e09b114c0 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -36,7 +36,7 @@ const char TAG_CONNECT[] = "#connect"; const char TAG_DISCONNECT[] = "#disconnect"; const char DEVTOOLS_PATH[] = "/node"; -const char DEVTOOLS_HASH[] = "521e5b7e2b7cc66b4006a8a54cb9c4e57494a5ef"; +const char DEVTOOLS_HASH[] = "851972d6da7463c353d712d2cb6c1ec23fa6c4fe"; void PrintDebuggerReadyMessage(int port) { fprintf(stderr, "Debugger listening on port %d.\n" From 4be6271c4391eee2e396662444645ebbf258bfc1 Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Tue, 19 Jul 2016 13:12:53 -0700 Subject: [PATCH 2/5] deps: remove jinja.el from deps/v8_inspector jinja.el is not shipped as part of the distribution, and neither is it used in the build. While not strictly necessary, removing it simplifies life from a licensing point of view. PR-URL: https://github.com/nodejs/node/pull/7796 Reviewed-By: bnoordhuis - Ben Noordhuis Reviewed-By: jasnell - James M Snell --- .../third_party/jinja2/ext/jinja.el | 128 ------------------ 1 file changed, 128 deletions(-) delete mode 100644 deps/v8_inspector/third_party/jinja2/ext/jinja.el diff --git a/deps/v8_inspector/third_party/jinja2/ext/jinja.el b/deps/v8_inspector/third_party/jinja2/ext/jinja.el deleted file mode 100644 index 4cf0c72e29af1d..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/ext/jinja.el +++ /dev/null @@ -1,128 +0,0 @@ -;;; jinja.el --- Jinja mode highlighting -;; -;; Author: Georg Brandl -;; Copyright: (c) 2009 by the Jinja Team -;; Last modified: 2008-05-22 23:04 by gbr -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Commentary: -;; -;; Mostly ripped off django-mode by Lennart Borgman. -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License as -;; published by the Free Software Foundation; either version 2, or -;; (at your option) any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;; General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with this program; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth -;; Floor, Boston, MA 02110-1301, USA. -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Code: - -(defconst jinja-font-lock-keywords - (list -; (cons (rx "{% comment %}" (submatch (0+ anything)) -; "{% endcomment %}") (list 1 font-lock-comment-face)) - '("{# ?\\(.*?\\) ?#}" . (1 font-lock-comment-face)) - '("{%-?\\|-?%}\\|{{\\|}}" . font-lock-preprocessor-face) - '("{#\\|#}" . font-lock-comment-delimiter-face) - ;; first word in a block is a command - '("{%-?[ \t\n]*\\([a-zA-Z_]+\\)" . (1 font-lock-keyword-face)) - ;; variables - '("\\({{ ?\\)\\([^|]*?\\)\\(|.*?\\)? ?}}" . (1 font-lock-variable-name-face)) - ;; keywords and builtins - (cons (rx word-start - (or "in" "as" "recursive" "not" "and" "or" "if" "else" - "import" "with" "without" "context") - word-end) - font-lock-keyword-face) - (cons (rx word-start - (or "true" "false" "none" "loop" "self" "super") - word-end) - font-lock-builtin-face) - ;; tests - '("\\(is\\)[ \t]*\\(not\\)[ \t]*\\([a-zA-Z_]+\\)" - (1 font-lock-keyword-face) (2 font-lock-keyword-face) - (3 font-lock-function-name-face)) - ;; builtin filters - (cons (rx - "|" (* space) - (submatch - (or "abs" "batch" "capitalize" "capture" "center" "count" "default" - "dformat" "dictsort" "e" "escape" "filesizeformat" "first" - "float" "format" "getattribute" "getitem" "groupby" "indent" - "int" "join" "jsonencode" "last" "length" "lower" "markdown" - "pprint" "random" "replace" "reverse" "round" "rst" "slice" - "sort" "string" "striptags" "sum" "textile" "title" "trim" - "truncate" "upper" "urlencode" "urlize" "wordcount" "wordwrap" - "xmlattr"))) - (list 1 font-lock-builtin-face)) - ) - "Minimal highlighting expressions for Jinja mode") - -(define-derived-mode jinja-mode nil "Jinja" - "Simple Jinja mode for use with `mumamo-mode'. -This mode only provides syntax highlighting." - ;;(set (make-local-variable 'comment-start) "{#") - ;;(set (make-local-variable 'comment-end) "#}") - (setq font-lock-defaults '(jinja-font-lock-keywords))) - -;; mumamo stuff -(when (require 'mumamo nil t) - - (defun mumamo-chunk-jinja3 (pos max) - "Find {# ... #}" - (mumamo-quick-chunk-forward pos max "{#" "#}" 'borders 'jinja-mode)) - - (defun mumamo-chunk-jinja2 (pos max) - "Find {{ ... }}" - (mumamo-quick-chunk-forward pos max "{{" "}}" 'borders 'jinja-mode)) - - (defun mumamo-chunk-jinja (pos max) - "Find {% ... %}" - (mumamo-quick-chunk-forward pos max "{%" "%}" 'borders 'jinja-mode)) - -;;;###autoload - (define-mumamo-multi-major-mode jinja-html-mumamo - "Turn on multiple major modes for Jinja with main mode `html-mode'. -This also covers inlined style and javascript." - ("Jinja HTML Family" html-mode - (mumamo-chunk-jinja - mumamo-chunk-jinja2 - mumamo-chunk-jinja3 - mumamo-chunk-inlined-style - mumamo-chunk-inlined-script - mumamo-chunk-style= - mumamo-chunk-onjs= - ))) - -;;;###autoload - (define-mumamo-multi-major-mode jinja-nxhtml-mumamo - "Turn on multiple major modes for Jinja with main mode `nxhtml-mode'. -This also covers inlined style and javascript." - ("Jinja nXhtml Family" nxhtml-mode - (mumamo-chunk-jinja - mumamo-chunk-jinja2 - mumamo-chunk-jinja3 - mumamo-chunk-inlined-style - mumamo-chunk-inlined-script - mumamo-chunk-style= - mumamo-chunk-onjs= - ))) - ) - -(provide 'jinja) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; jinja.el ends here From 3534600185322bd6e992f6f4d5596a418307cbc5 Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Wed, 20 Jul 2016 15:39:48 -0700 Subject: [PATCH 3/5] tools: update license-builder.sh for v8_inspector Start including the license from v8_inspector and its build time dependencies: jinja2 and markupsafe. PR-URL: https://github.com/nodejs/node/pull/7796 Reviewed-By: bnoordhuis - Ben Noordhuis Reviewed-By: jasnell - James M Snell --- tools/license-builder.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/license-builder.sh b/tools/license-builder.sh index eb3980e7d027cd..94da24ebeb3d74 100755 --- a/tools/license-builder.sh +++ b/tools/license-builder.sh @@ -82,5 +82,15 @@ addlicense "gtest" "deps/gtest" "$(cat ${rootdir}/deps/gtest/LICENSE)" addlicense "node-weak" "test/gc/node_modules/weak" \ "$(cat ${rootdir}/test/gc/node_modules/weak/LICENSE)" +# v8_inspector +addlicense "v8_inspector" "deps/v8_inspector/third_party/v8_inspector" \ + "$(cat ${rootdir}/deps/v8_inspector/third_party/v8_inspector/LICENSE)" +# Build tooling for v8_inspector +addlicense "jinja2" "deps/v8_inspector/third_party/jinja2" \ + "$(cat ${rootdir}/deps/v8_inspector/third_party/jinja2/LICENSE)" +addlicense "markupsafe" "deps/v8_inspector/third_party/markupsafe" \ + "$(cat ${rootdir}/deps/v8_inspector/third_party/markupsafe/LICENSE)" + + mv $tmplicense $licensefile From 7db495ab6d65d632a1d30cc5eacd99ffbe9ca5db Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Wed, 20 Jul 2016 15:42:42 -0700 Subject: [PATCH 4/5] doc: update licenses Created using `tools/license-builder.sh`. PR-URL: https://github.com/nodejs/node/pull/7796 Reviewed-By: bnoordhuis - Ben Noordhuis Reviewed-By: jasnell - James M Snell --- LICENSE | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index afe38dd748c7b7..254d5484323b93 100644 --- a/LICENSE +++ b/LICENSE @@ -96,7 +96,7 @@ The externally maintained libraries used by Node.js are: IN THE SOFTWARE. """ -- ICU, located at deps/icu, is licensed as follows: +- ICU, located at deps/icu-small, is licensed as follows: """ ICU License - ICU 1.8.1 and later @@ -1094,3 +1094,106 @@ The externally maintained libraries used by Node.js are: ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ + +- v8_inspector, located at deps/v8_inspector/third_party/v8_inspector, is licensed as follows: + """ + // Copyright 2015 The Chromium Authors. All rights reserved. + // + // Redistribution and use in source and binary forms, with or without + // modification, are permitted provided that the following conditions are + // met: + // + // * Redistributions of source code must retain the above copyright + // notice, this list of conditions and the following disclaimer. + // * Redistributions in binary form must reproduce the above + // copyright notice, this list of conditions and the following disclaimer + // in the documentation and/or other materials provided with the + // distribution. + // * Neither the name of Google Inc. nor the names of its + // contributors may be used to endorse or promote products derived from + // this software without specific prior written permission. + // + // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + """ + +- jinja2, located at deps/v8_inspector/third_party/jinja2, is licensed as follows: + """ + Copyright (c) 2009 by the Jinja Team, see AUTHORS for more details. + + Some rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * The names of the contributors may not be used to endorse or + promote products derived from this software without specific + prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + """ + +- markupsafe, located at deps/v8_inspector/third_party/markupsafe, is licensed as follows: + """ + Copyright (c) 2010 by Armin Ronacher and contributors. See AUTHORS + for more details. + + Some rights reserved. + + Redistribution and use in source and binary forms of the software as well + as documentation, with or without modification, are permitted provided + that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * The names of the contributors may not be used to endorse or + promote products derived from this software without specific + prior written permission. + + THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND + CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT + NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + DAMAGE. + """ From 2554549ab5410745c4312a3b039e31e1620e05ab Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Mon, 25 Jul 2016 11:41:11 -0700 Subject: [PATCH 5/5] deps: v8_inspector: remove jinja2 tests PR-URL: https://github.com/nodejs/node/pull/7796 Reviewed-By: bnoordhuis - Ben Noordhuis Reviewed-By: jasnell - James M Snell --- .../third_party/jinja2/tests/conftest.py | 74 --- .../third_party/jinja2/tests/res/__init__.py | 0 .../jinja2/tests/res/templates/broken.html | 3 - .../jinja2/tests/res/templates/foo/test.html | 1 - .../tests/res/templates/syntaxerror.html | 4 - .../jinja2/tests/res/templates/test.html | 1 - .../third_party/jinja2/tests/test_api.py | 327 ---------- .../jinja2/tests/test_bytecode_cache.py | 32 - .../jinja2/tests/test_core_tags.py | 337 ---------- .../third_party/jinja2/tests/test_debug.py | 73 --- .../third_party/jinja2/tests/test_ext.py | 467 -------------- .../third_party/jinja2/tests/test_filters.py | 558 ---------------- .../third_party/jinja2/tests/test_imports.py | 148 ----- .../jinja2/tests/test_inheritance.py | 248 ------- .../jinja2/tests/test_lexnparse.py | 609 ------------------ .../third_party/jinja2/tests/test_loader.py | 220 ------- .../jinja2/tests/test_regression.py | 278 -------- .../third_party/jinja2/tests/test_security.py | 161 ----- .../third_party/jinja2/tests/test_tests.py | 104 --- .../third_party/jinja2/tests/test_utils.py | 76 --- 20 files changed, 3721 deletions(-) delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/conftest.py delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/res/__init__.py delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/res/templates/broken.html delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/res/templates/foo/test.html delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/res/templates/syntaxerror.html delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/res/templates/test.html delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/test_api.py delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/test_bytecode_cache.py delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/test_core_tags.py delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/test_debug.py delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/test_ext.py delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/test_filters.py delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/test_imports.py delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/test_inheritance.py delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/test_lexnparse.py delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/test_loader.py delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/test_regression.py delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/test_security.py delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/test_tests.py delete mode 100644 deps/v8_inspector/third_party/jinja2/tests/test_utils.py diff --git a/deps/v8_inspector/third_party/jinja2/tests/conftest.py b/deps/v8_inspector/third_party/jinja2/tests/conftest.py deleted file mode 100644 index b5582323d7ee46..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/conftest.py +++ /dev/null @@ -1,74 +0,0 @@ -# -*- coding: utf-8 -*- -""" - jinja2.testsuite.conftest - ~~~~~~~~~~~~~~~~~~~~~~~~~ - - Configuration and Fixtures for the tests - - :copyright: (c) 2010 by the Jinja Team. - :license: BSD, see LICENSE for more details. -""" -import pytest -import os -import re -import sys - -from traceback import format_exception -from jinja2 import loaders -from jinja2._compat import PY2 -from jinja2 import Environment - - -@pytest.fixture -def env(): - '''returns a new environment. - ''' - return Environment() - - -@pytest.fixture -def dict_loader(): - '''returns DictLoader - ''' - return loaders.DictLoader({ - 'justdict.html': 'FOO' - }) - - -@pytest.fixture -def package_loader(): - '''returns PackageLoader initialized from templates - ''' - return loaders.PackageLoader('res', 'templates') - - -@pytest.fixture -def filesystem_loader(): - '''returns FileSystemLoader initialized to res/templates directory - ''' - here = os.path.dirname(os.path.abspath(__file__)) - return loaders.FileSystemLoader(here + '/res/templates') - - -@pytest.fixture -def function_loader(): - '''returns a FunctionLoader - ''' - return loaders.FunctionLoader({'justfunction.html': 'FOO'}.get) - - -@pytest.fixture -def choice_loader(dict_loader, package_loader): - '''returns a ChoiceLoader - ''' - return loaders.ChoiceLoader([dict_loader, package_loader]) - - -@pytest.fixture -def prefix_loader(filesystem_loader, dict_loader): - '''returns a PrefixLoader - ''' - return loaders.PrefixLoader({ - 'a': filesystem_loader, - 'b': dict_loader - }) diff --git a/deps/v8_inspector/third_party/jinja2/tests/res/__init__.py b/deps/v8_inspector/third_party/jinja2/tests/res/__init__.py deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/deps/v8_inspector/third_party/jinja2/tests/res/templates/broken.html b/deps/v8_inspector/third_party/jinja2/tests/res/templates/broken.html deleted file mode 100644 index 77669fae57cdc2..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/res/templates/broken.html +++ /dev/null @@ -1,3 +0,0 @@ -Before -{{ fail() }} -After diff --git a/deps/v8_inspector/third_party/jinja2/tests/res/templates/foo/test.html b/deps/v8_inspector/third_party/jinja2/tests/res/templates/foo/test.html deleted file mode 100644 index b7d6715e2df11b..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/res/templates/foo/test.html +++ /dev/null @@ -1 +0,0 @@ -FOO diff --git a/deps/v8_inspector/third_party/jinja2/tests/res/templates/syntaxerror.html b/deps/v8_inspector/third_party/jinja2/tests/res/templates/syntaxerror.html deleted file mode 100644 index f21b817939831b..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/res/templates/syntaxerror.html +++ /dev/null @@ -1,4 +0,0 @@ -Foo -{% for item in broken %} - ... -{% endif %} diff --git a/deps/v8_inspector/third_party/jinja2/tests/res/templates/test.html b/deps/v8_inspector/third_party/jinja2/tests/res/templates/test.html deleted file mode 100644 index ba578e48b18366..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/res/templates/test.html +++ /dev/null @@ -1 +0,0 @@ -BAR diff --git a/deps/v8_inspector/third_party/jinja2/tests/test_api.py b/deps/v8_inspector/third_party/jinja2/tests/test_api.py deleted file mode 100644 index 99d8dc1e13ea99..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/test_api.py +++ /dev/null @@ -1,327 +0,0 @@ -# -*- coding: utf-8 -*- -""" - jinja2.testsuite.api - ~~~~~~~~~~~~~~~~~~~~ - - Tests the public API and related stuff. - - :copyright: (c) 2010 by the Jinja Team. - :license: BSD, see LICENSE for more details. -""" -import os -import tempfile -import shutil - -import pytest -from jinja2 import Environment, Undefined, DebugUndefined, \ - StrictUndefined, UndefinedError, meta, \ - is_undefined, Template, DictLoader, make_logging_undefined -from jinja2.compiler import CodeGenerator -from jinja2.runtime import Context -from jinja2.utils import Cycler - - -@pytest.mark.api -@pytest.mark.extended -class TestExtendedAPI(): - - def test_item_and_attribute(self, env): - from jinja2.sandbox import SandboxedEnvironment - - for env in Environment(), SandboxedEnvironment(): - # the |list is necessary for python3 - tmpl = env.from_string('{{ foo.items()|list }}') - assert tmpl.render(foo={'items': 42}) == "[('items', 42)]" - tmpl = env.from_string('{{ foo|attr("items")()|list }}') - assert tmpl.render(foo={'items': 42}) == "[('items', 42)]" - tmpl = env.from_string('{{ foo["items"] }}') - assert tmpl.render(foo={'items': 42}) == '42' - - def test_finalizer(self, env): - def finalize_none_empty(value): - if value is None: - value = u'' - return value - env = Environment(finalize=finalize_none_empty) - tmpl = env.from_string('{% for item in seq %}|{{ item }}{% endfor %}') - assert tmpl.render(seq=(None, 1, "foo")) == '||1|foo' - tmpl = env.from_string('<{{ none }}>') - assert tmpl.render() == '<>' - - def test_cycler(self, env): - items = 1, 2, 3 - c = Cycler(*items) - for item in items + items: - assert c.current == item - assert next(c) == item - next(c) - assert c.current == 2 - c.reset() - assert c.current == 1 - - def test_expressions(self, env): - expr = env.compile_expression("foo") - assert expr() is None - assert expr(foo=42) == 42 - expr2 = env.compile_expression("foo", undefined_to_none=False) - assert is_undefined(expr2()) - - expr = env.compile_expression("42 + foo") - assert expr(foo=42) == 84 - - def test_template_passthrough(self, env): - t = Template('Content') - assert env.get_template(t) is t - assert env.select_template([t]) is t - assert env.get_or_select_template([t]) is t - assert env.get_or_select_template(t) is t - - def test_autoescape_autoselect(self, env): - def select_autoescape(name): - if name is None or '.' not in name: - return False - return name.endswith('.html') - env = Environment(autoescape=select_autoescape, - loader=DictLoader({ - 'test.txt': '{{ foo }}', - 'test.html': '{{ foo }}' - })) - t = env.get_template('test.txt') - assert t.render(foo='') == '' - t = env.get_template('test.html') - assert t.render(foo='') == '<foo>' - t = env.from_string('{{ foo }}') - assert t.render(foo='') == '' - - -@pytest.mark.api -@pytest.mark.meta -class TestMeta(): - - def test_find_undeclared_variables(self, env): - ast = env.parse('{% set foo = 42 %}{{ bar + foo }}') - x = meta.find_undeclared_variables(ast) - assert x == set(['bar']) - - ast = env.parse('{% set foo = 42 %}{{ bar + foo }}' - '{% macro meh(x) %}{{ x }}{% endmacro %}' - '{% for item in seq %}{{ muh(item) + meh(seq) }}' - '{% endfor %}') - x = meta.find_undeclared_variables(ast) - assert x == set(['bar', 'seq', 'muh']) - - def test_find_refererenced_templates(self, env): - ast = env.parse('{% extends "layout.html" %}{% include helper %}') - i = meta.find_referenced_templates(ast) - assert next(i) == 'layout.html' - assert next(i) is None - assert list(i) == [] - - ast = env.parse('{% extends "layout.html" %}' - '{% from "test.html" import a, b as c %}' - '{% import "meh.html" as meh %}' - '{% include "muh.html" %}') - i = meta.find_referenced_templates(ast) - assert list(i) == ['layout.html', 'test.html', 'meh.html', 'muh.html'] - - def test_find_included_templates(self, env): - ast = env.parse('{% include ["foo.html", "bar.html"] %}') - i = meta.find_referenced_templates(ast) - assert list(i) == ['foo.html', 'bar.html'] - - ast = env.parse('{% include ("foo.html", "bar.html") %}') - i = meta.find_referenced_templates(ast) - assert list(i) == ['foo.html', 'bar.html'] - - ast = env.parse('{% include ["foo.html", "bar.html", foo] %}') - i = meta.find_referenced_templates(ast) - assert list(i) == ['foo.html', 'bar.html', None] - - ast = env.parse('{% include ("foo.html", "bar.html", foo) %}') - i = meta.find_referenced_templates(ast) - assert list(i) == ['foo.html', 'bar.html', None] - - -@pytest.mark.api -@pytest.mark.streaming -class TestStreaming(): - - def test_basic_streaming(self, env): - tmpl = env.from_string("
    {% for item in seq %}
  • {{ loop.index " - "}} - {{ item }}
  • {%- endfor %}
") - stream = tmpl.stream(seq=list(range(4))) - assert next(stream) == '
    ' - assert next(stream) == '
  • 1 - 0
  • ' - assert next(stream) == '
  • 2 - 1
  • ' - assert next(stream) == '
  • 3 - 2
  • ' - assert next(stream) == '
  • 4 - 3
  • ' - assert next(stream) == '
' - - def test_buffered_streaming(self, env): - tmpl = env.from_string("
    {% for item in seq %}
  • {{ loop.index " - "}} - {{ item }}
  • {%- endfor %}
") - stream = tmpl.stream(seq=list(range(4))) - stream.enable_buffering(size=3) - assert next(stream) == u'
  • 1 - 0
  • 2 - 1
  • ' - assert next(stream) == u'
  • 3 - 2
  • 4 - 3
' - - def test_streaming_behavior(self, env): - tmpl = env.from_string("") - stream = tmpl.stream() - assert not stream.buffered - stream.enable_buffering(20) - assert stream.buffered - stream.disable_buffering() - assert not stream.buffered - - def test_dump_stream(self, env): - tmp = tempfile.mkdtemp() - try: - tmpl = env.from_string(u"\u2713") - stream = tmpl.stream() - stream.dump(os.path.join(tmp, 'dump.txt'), 'utf-8') - with open(os.path.join(tmp, 'dump.txt'), 'rb') as f: - assert f.read() == b'\xe2\x9c\x93' - finally: - shutil.rmtree(tmp) - - -@pytest.mark.api -@pytest.mark.undefined -class TestUndefined(): - - def test_stopiteration_is_undefined(self): - def test(): - raise StopIteration() - t = Template('A{{ test() }}B') - assert t.render(test=test) == 'AB' - t = Template('A{{ test().missingattribute }}B') - pytest.raises(UndefinedError, t.render, test=test) - - def test_undefined_and_special_attributes(self): - try: - Undefined('Foo').__dict__ - except AttributeError: - pass - else: - assert False, "Expected actual attribute error" - - def test_logging_undefined(self): - _messages = [] - - class DebugLogger(object): - def warning(self, msg, *args): - _messages.append('W:' + msg % args) - - def error(self, msg, *args): - _messages.append('E:' + msg % args) - - logging_undefined = make_logging_undefined(DebugLogger()) - env = Environment(undefined=logging_undefined) - assert env.from_string('{{ missing }}').render() == u'' - pytest.raises(UndefinedError, - env.from_string('{{ missing.attribute }}').render) - assert env.from_string('{{ missing|list }}').render() == '[]' - assert env.from_string('{{ missing is not defined }}').render() \ - == 'True' - assert env.from_string('{{ foo.missing }}').render(foo=42) == '' - assert env.from_string('{{ not missing }}').render() == 'True' - assert _messages == [ - 'W:Template variable warning: missing is undefined', - "E:Template variable error: 'missing' is undefined", - 'W:Template variable warning: missing is undefined', - 'W:Template variable warning: int object has no attribute missing', - 'W:Template variable warning: missing is undefined', - ] - - def test_default_undefined(self): - env = Environment(undefined=Undefined) - assert env.from_string('{{ missing }}').render() == u'' - pytest.raises(UndefinedError, - env.from_string('{{ missing.attribute }}').render) - assert env.from_string('{{ missing|list }}').render() == '[]' - assert env.from_string('{{ missing is not defined }}').render() \ - == 'True' - assert env.from_string('{{ foo.missing }}').render(foo=42) == '' - assert env.from_string('{{ not missing }}').render() == 'True' - - def test_debug_undefined(self): - env = Environment(undefined=DebugUndefined) - assert env.from_string('{{ missing }}').render() == '{{ missing }}' - pytest.raises(UndefinedError, - env.from_string('{{ missing.attribute }}').render) - assert env.from_string('{{ missing|list }}').render() == '[]' - assert env.from_string('{{ missing is not defined }}').render() \ - == 'True' - assert env.from_string('{{ foo.missing }}').render(foo=42) \ - == u"{{ no such element: int object['missing'] }}" - assert env.from_string('{{ not missing }}').render() == 'True' - - def test_strict_undefined(self): - env = Environment(undefined=StrictUndefined) - pytest.raises(UndefinedError, env.from_string('{{ missing }}').render) - pytest.raises(UndefinedError, - env.from_string('{{ missing.attribute }}').render) - pytest.raises(UndefinedError, - env.from_string('{{ missing|list }}').render) - assert env.from_string('{{ missing is not defined }}').render() \ - == 'True' - pytest.raises(UndefinedError, - env.from_string('{{ foo.missing }}').render, foo=42) - pytest.raises(UndefinedError, - env.from_string('{{ not missing }}').render) - assert env.from_string('{{ missing|default("default", true) }}')\ - .render() == 'default' - - def test_indexing_gives_undefined(self): - t = Template("{{ var[42].foo }}") - pytest.raises(UndefinedError, t.render, var=0) - - def test_none_gives_proper_error(self): - try: - Environment().getattr(None, 'split')() - except UndefinedError as e: - assert e.message == "'None' has no attribute 'split'" - else: - assert False, 'expected exception' - - def test_object_repr(self): - try: - Undefined(obj=42, name='upper')() - except UndefinedError as e: - assert e.message == "'int object' has no attribute 'upper'" - else: - assert False, 'expected exception' - - -@pytest.mark.api -@pytest.mark.lowlevel -class TestLowLevel(): - - def test_custom_code_generator(self): - class CustomCodeGenerator(CodeGenerator): - def visit_Const(self, node, frame=None): - # This method is pure nonsense, but works fine for testing... - if node.value == 'foo': - self.write(repr('bar')) - else: - super(CustomCodeGenerator, self).visit_Const(node, frame) - - class CustomEnvironment(Environment): - code_generator_class = CustomCodeGenerator - - env = CustomEnvironment() - tmpl = env.from_string('{% set foo = "foo" %}{{ foo }}') - assert tmpl.render() == 'bar' - - def test_custom_context(self): - class CustomContext(Context): - def resolve(self, key): - return 'resolve-' + key - - class CustomEnvironment(Environment): - context_class = CustomContext - - env = CustomEnvironment() - tmpl = env.from_string('{{ foo }}') - assert tmpl.render() == 'resolve-foo' diff --git a/deps/v8_inspector/third_party/jinja2/tests/test_bytecode_cache.py b/deps/v8_inspector/third_party/jinja2/tests/test_bytecode_cache.py deleted file mode 100644 index 2ffe4c60379bc4..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/test_bytecode_cache.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- -""" - jinja2.testsuite.bytecode_cache - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - Test bytecode caching - - :copyright: (c) 2010 by the Jinja Team. - :license: BSD, see LICENSE for more details. -""" -import pytest -from jinja2 import Environment -from jinja2.bccache import FileSystemBytecodeCache -from jinja2.exceptions import TemplateNotFound - - -@pytest.fixture -def env(package_loader): - bytecode_cache = FileSystemBytecodeCache() - return Environment( - loader=package_loader, - bytecode_cache=bytecode_cache, - ) - - -@pytest.mark.byte_code_cache -class TestByteCodeCache(): - - def test_simple(self, env): - tmpl = env.get_template('test.html') - assert tmpl.render().strip() == 'BAR' - pytest.raises(TemplateNotFound, env.get_template, 'missing.html') diff --git a/deps/v8_inspector/third_party/jinja2/tests/test_core_tags.py b/deps/v8_inspector/third_party/jinja2/tests/test_core_tags.py deleted file mode 100644 index 2ea7757e4862aa..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/test_core_tags.py +++ /dev/null @@ -1,337 +0,0 @@ -# -*- coding: utf-8 -*- -""" - jinja2.testsuite.core_tags - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - - Test the core tags like for and if. - - :copyright: (c) 2010 by the Jinja Team. - :license: BSD, see LICENSE for more details. -""" -import pytest -from jinja2 import Environment, TemplateSyntaxError, UndefinedError, \ - DictLoader - - -@pytest.fixture -def env_trim(): - return Environment(trim_blocks=True) - - -@pytest.mark.core_tags -@pytest.mark.for_loop -class TestForLoop(): - - def test_simple(self, env): - tmpl = env.from_string('{% for item in seq %}{{ item }}{% endfor %}') - assert tmpl.render(seq=list(range(10))) == '0123456789' - - def test_else(self, env): - tmpl = env.from_string( - '{% for item in seq %}XXX{% else %}...{% endfor %}') - assert tmpl.render() == '...' - - def test_empty_blocks(self, env): - tmpl = env.from_string('<{% for item in seq %}{% else %}{% endfor %}>') - assert tmpl.render() == '<>' - - def test_context_vars(self, env): - slist = [42, 24] - for seq in [slist, iter(slist), reversed(slist), (_ for _ in slist)]: - tmpl = env.from_string('''{% for item in seq -%} - {{ loop.index }}|{{ loop.index0 }}|{{ loop.revindex }}|{{ - loop.revindex0 }}|{{ loop.first }}|{{ loop.last }}|{{ - loop.length }}###{% endfor %}''') - one, two, _ = tmpl.render(seq=seq).split('###') - (one_index, one_index0, one_revindex, one_revindex0, one_first, - one_last, one_length) = one.split('|') - (two_index, two_index0, two_revindex, two_revindex0, two_first, - two_last, two_length) = two.split('|') - - assert int(one_index) == 1 and int(two_index) == 2 - assert int(one_index0) == 0 and int(two_index0) == 1 - assert int(one_revindex) == 2 and int(two_revindex) == 1 - assert int(one_revindex0) == 1 and int(two_revindex0) == 0 - assert one_first == 'True' and two_first == 'False' - assert one_last == 'False' and two_last == 'True' - assert one_length == two_length == '2' - - def test_cycling(self, env): - tmpl = env.from_string('''{% for item in seq %}{{ - loop.cycle('<1>', '<2>') }}{% endfor %}{% - for item in seq %}{{ loop.cycle(*through) }}{% endfor %}''') - output = tmpl.render(seq=list(range(4)), through=('<1>', '<2>')) - assert output == '<1><2>' * 4 - - def test_scope(self, env): - tmpl = env.from_string('{% for item in seq %}{% endfor %}{{ item }}') - output = tmpl.render(seq=list(range(10))) - assert not output - - def test_varlen(self, env): - def inner(): - for item in range(5): - yield item - tmpl = env.from_string('{% for item in iter %}{{ item }}{% endfor %}') - output = tmpl.render(iter=inner()) - assert output == '01234' - - def test_noniter(self, env): - tmpl = env.from_string('{% for item in none %}...{% endfor %}') - pytest.raises(TypeError, tmpl.render) - - def test_recursive(self, env): - tmpl = env.from_string('''{% for item in seq recursive -%} - [{{ item.a }}{% if item.b %}<{{ loop(item.b) }}>{% endif %}] - {%- endfor %}''') - assert tmpl.render(seq=[ - dict(a=1, b=[dict(a=1), dict(a=2)]), - dict(a=2, b=[dict(a=1), dict(a=2)]), - dict(a=3, b=[dict(a='a')]) - ]) == '[1<[1][2]>][2<[1][2]>][3<[a]>]' - - def test_recursive_depth0(self, env): - tmpl = env.from_string('''{% for item in seq recursive -%} - [{{ loop.depth0 }}:{{ item.a }}{% if item.b %}<{{ loop(item.b) }}>{% endif %}] - {%- endfor %}''') - assert tmpl.render(seq=[ - dict(a=1, b=[dict(a=1), dict(a=2)]), - dict(a=2, b=[dict(a=1), dict(a=2)]), - dict(a=3, b=[dict(a='a')]) - ]) == '[0:1<[1:1][1:2]>][0:2<[1:1][1:2]>][0:3<[1:a]>]' - - def test_recursive_depth(self, env): - tmpl = env.from_string('''{% for item in seq recursive -%} - [{{ loop.depth }}:{{ item.a }}{% if item.b %}<{{ loop(item.b) }}>{% endif %}] - {%- endfor %}''') - assert tmpl.render(seq=[ - dict(a=1, b=[dict(a=1), dict(a=2)]), - dict(a=2, b=[dict(a=1), dict(a=2)]), - dict(a=3, b=[dict(a='a')]) - ]) == '[1:1<[2:1][2:2]>][1:2<[2:1][2:2]>][1:3<[2:a]>]' - - def test_looploop(self, env): - tmpl = env.from_string('''{% for row in table %} - {%- set rowloop = loop -%} - {% for cell in row -%} - [{{ rowloop.index }}|{{ loop.index }}] - {%- endfor %} - {%- endfor %}''') - assert tmpl.render(table=['ab', 'cd']) == '[1|1][1|2][2|1][2|2]' - - def test_reversed_bug(self, env): - tmpl = env.from_string('{% for i in items %}{{ i }}' - '{% if not loop.last %}' - ',{% endif %}{% endfor %}') - assert tmpl.render(items=reversed([3, 2, 1])) == '1,2,3' - - def test_loop_errors(self, env): - tmpl = env.from_string('''{% for item in [1] if loop.index - == 0 %}...{% endfor %}''') - pytest.raises(UndefinedError, tmpl.render) - tmpl = env.from_string('''{% for item in [] %}...{% else - %}{{ loop }}{% endfor %}''') - assert tmpl.render() == '' - - def test_loop_filter(self, env): - tmpl = env.from_string('{% for item in range(10) if item ' - 'is even %}[{{ item }}]{% endfor %}') - assert tmpl.render() == '[0][2][4][6][8]' - tmpl = env.from_string(''' - {%- for item in range(10) if item is even %}[{{ - loop.index }}:{{ item }}]{% endfor %}''') - assert tmpl.render() == '[1:0][2:2][3:4][4:6][5:8]' - - def test_loop_unassignable(self, env): - pytest.raises(TemplateSyntaxError, env.from_string, - '{% for loop in seq %}...{% endfor %}') - - def test_scoped_special_var(self, env): - t = env.from_string( - '{% for s in seq %}[{{ loop.first }}{% for c in s %}' - '|{{ loop.first }}{% endfor %}]{% endfor %}') - assert t.render(seq=('ab', 'cd')) \ - == '[True|True|False][False|True|False]' - - def test_scoped_loop_var(self, env): - t = env.from_string('{% for x in seq %}{{ loop.first }}' - '{% for y in seq %}{% endfor %}{% endfor %}') - assert t.render(seq='ab') == 'TrueFalse' - t = env.from_string('{% for x in seq %}{% for y in seq %}' - '{{ loop.first }}{% endfor %}{% endfor %}') - assert t.render(seq='ab') == 'TrueFalseTrueFalse' - - def test_recursive_empty_loop_iter(self, env): - t = env.from_string(''' - {%- for item in foo recursive -%}{%- endfor -%} - ''') - assert t.render(dict(foo=[])) == '' - - def test_call_in_loop(self, env): - t = env.from_string(''' - {%- macro do_something() -%} - [{{ caller() }}] - {%- endmacro %} - - {%- for i in [1, 2, 3] %} - {%- call do_something() -%} - {{ i }} - {%- endcall %} - {%- endfor -%} - ''') - assert t.render() == '[1][2][3]' - - def test_scoping_bug(self, env): - t = env.from_string(''' - {%- for item in foo %}...{{ item }}...{% endfor %} - {%- macro item(a) %}...{{ a }}...{% endmacro %} - {{- item(2) -}} - ''') - assert t.render(foo=(1,)) == '...1......2...' - - def test_unpacking(self, env): - tmpl = env.from_string('{% for a, b, c in [[1, 2, 3]] %}' - '{{ a }}|{{ b }}|{{ c }}{% endfor %}') - assert tmpl.render() == '1|2|3' - - -@pytest.mark.core_tags -@pytest.mark.if_condition -class TestIfCondition(): - - def test_simple(self, env): - tmpl = env.from_string('''{% if true %}...{% endif %}''') - assert tmpl.render() == '...' - - def test_elif(self, env): - tmpl = env.from_string('''{% if false %}XXX{% elif true - %}...{% else %}XXX{% endif %}''') - assert tmpl.render() == '...' - - def test_else(self, env): - tmpl = env.from_string('{% if false %}XXX{% else %}...{% endif %}') - assert tmpl.render() == '...' - - def test_empty(self, env): - tmpl = env.from_string('[{% if true %}{% else %}{% endif %}]') - assert tmpl.render() == '[]' - - def test_complete(self, env): - tmpl = env.from_string('{% if a %}A{% elif b %}B{% elif c == d %}' - 'C{% else %}D{% endif %}') - assert tmpl.render(a=0, b=False, c=42, d=42.0) == 'C' - - def test_no_scope(self, env): - tmpl = env.from_string( - '{% if a %}{% set foo = 1 %}{% endif %}{{ foo }}') - assert tmpl.render(a=True) == '1' - tmpl = env.from_string( - '{% if true %}{% set foo = 1 %}{% endif %}{{ foo }}') - assert tmpl.render() == '1' - - -@pytest.mark.core_tags -@pytest.mark.macros -class TestMacros(): - def test_simple(self, env_trim): - tmpl = env_trim.from_string('''\ -{% macro say_hello(name) %}Hello {{ name }}!{% endmacro %} -{{ say_hello('Peter') }}''') - assert tmpl.render() == 'Hello Peter!' - - def test_scoping(self, env_trim): - tmpl = env_trim.from_string('''\ -{% macro level1(data1) %} -{% macro level2(data2) %}{{ data1 }}|{{ data2 }}{% endmacro %} -{{ level2('bar') }}{% endmacro %} -{{ level1('foo') }}''') - assert tmpl.render() == 'foo|bar' - - def test_arguments(self, env_trim): - tmpl = env_trim.from_string('''\ -{% macro m(a, b, c='c', d='d') %}{{ a }}|{{ b }}|{{ c }}|{{ d }}{% endmacro %} -{{ m() }}|{{ m('a') }}|{{ m('a', 'b') }}|{{ m(1, 2, 3) }}''') - assert tmpl.render() == '||c|d|a||c|d|a|b|c|d|1|2|3|d' - - def test_arguments_defaults_nonsense(self, env_trim): - pytest.raises(TemplateSyntaxError, env_trim.from_string, '''\ -{% macro m(a, b=1, c) %}a={{ a }}, b={{ b }}, c={{ c }}{% endmacro %}''') - - def test_caller_defaults_nonsense(self, env_trim): - pytest.raises(TemplateSyntaxError, env_trim.from_string, '''\ -{% macro a() %}{{ caller() }}{% endmacro %} -{% call(x, y=1, z) a() %}{% endcall %}''') - - def test_varargs(self, env_trim): - tmpl = env_trim.from_string('''\ -{% macro test() %}{{ varargs|join('|') }}{% endmacro %}\ -{{ test(1, 2, 3) }}''') - assert tmpl.render() == '1|2|3' - - def test_simple_call(self, env_trim): - tmpl = env_trim.from_string('''\ -{% macro test() %}[[{{ caller() }}]]{% endmacro %}\ -{% call test() %}data{% endcall %}''') - assert tmpl.render() == '[[data]]' - - def test_complex_call(self, env_trim): - tmpl = env_trim.from_string('''\ -{% macro test() %}[[{{ caller('data') }}]]{% endmacro %}\ -{% call(data) test() %}{{ data }}{% endcall %}''') - assert tmpl.render() == '[[data]]' - - def test_caller_undefined(self, env_trim): - tmpl = env_trim.from_string('''\ -{% set caller = 42 %}\ -{% macro test() %}{{ caller is not defined }}{% endmacro %}\ -{{ test() }}''') - assert tmpl.render() == 'True' - - def test_include(self, env_trim): - env_trim = Environment( - loader=DictLoader({ - 'include': '{% macro test(foo) %}[{{ foo }}]{% endmacro %}' - }) - ) - tmpl = env_trim.from_string( - '{% from "include" import test %}{{ test("foo") }}') - assert tmpl.render() == '[foo]' - - def test_macro_api(self, env_trim): - tmpl = env_trim.from_string( - '{% macro foo(a, b) %}{% endmacro %}' - '{% macro bar() %}{{ varargs }}{{ kwargs }}{% endmacro %}' - '{% macro baz() %}{{ caller() }}{% endmacro %}') - assert tmpl.module.foo.arguments == ('a', 'b') - assert tmpl.module.foo.defaults == () - assert tmpl.module.foo.name == 'foo' - assert not tmpl.module.foo.caller - assert not tmpl.module.foo.catch_kwargs - assert not tmpl.module.foo.catch_varargs - assert tmpl.module.bar.arguments == () - assert tmpl.module.bar.defaults == () - assert not tmpl.module.bar.caller - assert tmpl.module.bar.catch_kwargs - assert tmpl.module.bar.catch_varargs - assert tmpl.module.baz.caller - - def test_callself(self, env_trim): - tmpl = env_trim.from_string('{% macro foo(x) %}{{ x }}{% if x > 1 %}|' - '{{ foo(x - 1) }}{% endif %}{% endmacro %}' - '{{ foo(5) }}') - assert tmpl.render() == '5|4|3|2|1' - - -@pytest.mark.core_tags -@pytest.mark.set -class TestSet(): - - def test_normal(self, env_trim): - tmpl = env_trim.from_string('{% set foo = 1 %}{{ foo }}') - assert tmpl.render() == '1' - assert tmpl.module.foo == 1 - - def test_block(self, env_trim): - tmpl = env_trim.from_string('{% set foo %}42{% endset %}{{ foo }}') - assert tmpl.render() == '42' - assert tmpl.module.foo == u'42' diff --git a/deps/v8_inspector/third_party/jinja2/tests/test_debug.py b/deps/v8_inspector/third_party/jinja2/tests/test_debug.py deleted file mode 100644 index d8617ae08e1176..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/test_debug.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- coding: utf-8 -*- -""" - jinja2.testsuite.debug - ~~~~~~~~~~~~~~~~~~~~~~ - - Tests the debug system. - - :copyright: (c) 2010 by the Jinja Team. - :license: BSD, see LICENSE for more details. -""" -import pytest - -import re - -import sys -from traceback import format_exception - -from jinja2 import Environment, TemplateSyntaxError -from traceback import format_exception - - -@pytest.fixture -def fs_env(filesystem_loader): - '''returns a new environment. - ''' - return Environment(loader=filesystem_loader) - - -@pytest.mark.debug -class TestDebug(): - - def assert_traceback_matches(self, callback, expected_tb): - try: - callback() - except Exception as e: - tb = format_exception(*sys.exc_info()) - if re.search(expected_tb.strip(), ''.join(tb)) is None: - assert False, ('Traceback did not match:\n\n%s\nexpected:\n%s' % - (''.join(tb), expected_tb)) - else: - assert False, 'Expected exception' - - def test_runtime_error(self, fs_env): - def test(): - tmpl.render(fail=lambda: 1 / 0) - tmpl = fs_env.get_template('broken.html') - self.assert_traceback_matches(test, r''' - File ".*?broken.html", line 2, in (top-level template code|) - \{\{ fail\(\) \}\} - File ".*debug?.pyc?", line \d+, in - tmpl\.render\(fail=lambda: 1 / 0\) -ZeroDivisionError: (int(eger)? )?division (or modulo )?by zero -''') - - def test_syntax_error(self, fs_env): - # XXX: the .*? is necessary for python3 which does not hide - # some of the stack frames we don't want to show. Not sure - # what's up with that, but that is not that critical. Should - # be fixed though. - self.assert_traceback_matches(lambda: fs_env.get_template('syntaxerror.html'), r'''(?sm) - File ".*?syntaxerror.html", line 4, in (template|) - \{% endif %\}.*? -(jinja2\.exceptions\.)?TemplateSyntaxError: Encountered unknown tag 'endif'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'. - ''') - - def test_regular_syntax_error(self, fs_env): - def test(): - raise TemplateSyntaxError('wtf', 42) - self.assert_traceback_matches(test, r''' - File ".*debug.pyc?", line \d+, in test - raise TemplateSyntaxError\('wtf', 42\) -(jinja2\.exceptions\.)?TemplateSyntaxError: wtf - line 42''') diff --git a/deps/v8_inspector/third_party/jinja2/tests/test_ext.py b/deps/v8_inspector/third_party/jinja2/tests/test_ext.py deleted file mode 100644 index 8985416c9cb356..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/test_ext.py +++ /dev/null @@ -1,467 +0,0 @@ -# -*- coding: utf-8 -*- -""" - jinja2.testsuite.ext - ~~~~~~~~~~~~~~~~~~~~ - - Tests for the extensions. - - :copyright: (c) 2010 by the Jinja Team. - :license: BSD, see LICENSE for more details. -""" -import re -import pytest - -from jinja2 import Environment, DictLoader, contextfunction, nodes -from jinja2.exceptions import TemplateAssertionError -from jinja2.ext import Extension -from jinja2.lexer import Token, count_newlines -from jinja2._compat import BytesIO, itervalues, text_type - -importable_object = 23 - -_gettext_re = re.compile(r'_\((.*?)\)(?s)') - - -i18n_templates = { - 'master.html': '{{ page_title|default(_("missing")) }}' - '{% block body %}{% endblock %}', - 'child.html': '{% extends "master.html" %}{% block body %}' - '{% trans %}watch out{% endtrans %}{% endblock %}', - 'plural.html': '{% trans user_count %}One user online{% pluralize %}' - '{{ user_count }} users online{% endtrans %}', - 'plural2.html': '{% trans user_count=get_user_count() %}{{ user_count }}s' - '{% pluralize %}{{ user_count }}p{% endtrans %}', - 'stringformat.html': '{{ _("User: %(num)s")|format(num=user_count) }}' -} - -newstyle_i18n_templates = { - 'master.html': '{{ page_title|default(_("missing")) }}' - '{% block body %}{% endblock %}', - 'child.html': '{% extends "master.html" %}{% block body %}' - '{% trans %}watch out{% endtrans %}{% endblock %}', - 'plural.html': '{% trans user_count %}One user online{% pluralize %}' - '{{ user_count }} users online{% endtrans %}', - 'stringformat.html': '{{ _("User: %(num)s", num=user_count) }}', - 'ngettext.html': '{{ ngettext("%(num)s apple", "%(num)s apples", apples) }}', - 'ngettext_long.html': '{% trans num=apples %}{{ num }} apple{% pluralize %}' - '{{ num }} apples{% endtrans %}', - 'transvars1.html': '{% trans %}User: {{ num }}{% endtrans %}', - 'transvars2.html': '{% trans num=count %}User: {{ num }}{% endtrans %}', - 'transvars3.html': '{% trans count=num %}User: {{ count }}{% endtrans %}', - 'novars.html': '{% trans %}%(hello)s{% endtrans %}', - 'vars.html': '{% trans %}{{ foo }}%(foo)s{% endtrans %}', - 'explicitvars.html': '{% trans foo="42" %}%(foo)s{% endtrans %}' -} - - -languages = { - 'de': { - 'missing': u'fehlend', - 'watch out': u'pass auf', - 'One user online': u'Ein Benutzer online', - '%(user_count)s users online': u'%(user_count)s Benutzer online', - 'User: %(num)s': u'Benutzer: %(num)s', - 'User: %(count)s': u'Benutzer: %(count)s', - '%(num)s apple': u'%(num)s Apfel', - '%(num)s apples': u'%(num)s Äpfel' - } -} - - -@contextfunction -def gettext(context, string): - language = context.get('LANGUAGE', 'en') - return languages.get(language, {}).get(string, string) - - -@contextfunction -def ngettext(context, s, p, n): - language = context.get('LANGUAGE', 'en') - if n != 1: - return languages.get(language, {}).get(p, p) - return languages.get(language, {}).get(s, s) - - -i18n_env = Environment( - loader=DictLoader(i18n_templates), - extensions=['jinja2.ext.i18n'] -) -i18n_env.globals.update({ - '_': gettext, - 'gettext': gettext, - 'ngettext': ngettext -}) - -newstyle_i18n_env = Environment( - loader=DictLoader(newstyle_i18n_templates), - extensions=['jinja2.ext.i18n'] -) -newstyle_i18n_env.install_gettext_callables(gettext, ngettext, newstyle=True) - - -class TestExtension(Extension): - tags = set(['test']) - ext_attr = 42 - - def parse(self, parser): - return nodes.Output([self.call_method('_dump', [ - nodes.EnvironmentAttribute('sandboxed'), - self.attr('ext_attr'), - nodes.ImportedName(__name__ + '.importable_object'), - nodes.ContextReference() - ])]).set_lineno(next(parser.stream).lineno) - - def _dump(self, sandboxed, ext_attr, imported_object, context): - return '%s|%s|%s|%s' % ( - sandboxed, - ext_attr, - imported_object, - context.blocks - ) - - -class PreprocessorExtension(Extension): - - def preprocess(self, source, name, filename=None): - return source.replace('[[TEST]]', '({{ foo }})') - - -class StreamFilterExtension(Extension): - - def filter_stream(self, stream): - for token in stream: - if token.type == 'data': - for t in self.interpolate(token): - yield t - else: - yield token - - def interpolate(self, token): - pos = 0 - end = len(token.value) - lineno = token.lineno - while 1: - match = _gettext_re.search(token.value, pos) - if match is None: - break - value = token.value[pos:match.start()] - if value: - yield Token(lineno, 'data', value) - lineno += count_newlines(token.value) - yield Token(lineno, 'variable_begin', None) - yield Token(lineno, 'name', 'gettext') - yield Token(lineno, 'lparen', None) - yield Token(lineno, 'string', match.group(1)) - yield Token(lineno, 'rparen', None) - yield Token(lineno, 'variable_end', None) - pos = match.end() - if pos < end: - yield Token(lineno, 'data', token.value[pos:]) - - -@pytest.mark.ext -class TestExtensions(): - - def test_extend_late(self): - env = Environment() - env.add_extension('jinja2.ext.autoescape') - t = env.from_string( - '{% autoescape true %}{{ "" }}{% endautoescape %}') - assert t.render() == '<test>' - - def test_loop_controls(self): - env = Environment(extensions=['jinja2.ext.loopcontrols']) - - tmpl = env.from_string(''' - {%- for item in [1, 2, 3, 4] %} - {%- if item % 2 == 0 %}{% continue %}{% endif -%} - {{ item }} - {%- endfor %}''') - assert tmpl.render() == '13' - - tmpl = env.from_string(''' - {%- for item in [1, 2, 3, 4] %} - {%- if item > 2 %}{% break %}{% endif -%} - {{ item }} - {%- endfor %}''') - assert tmpl.render() == '12' - - def test_do(self): - env = Environment(extensions=['jinja2.ext.do']) - tmpl = env.from_string(''' - {%- set items = [] %} - {%- for char in "foo" %} - {%- do items.append(loop.index0 ~ char) %} - {%- endfor %}{{ items|join(', ') }}''') - assert tmpl.render() == '0f, 1o, 2o' - - def test_with(self): - env = Environment(extensions=['jinja2.ext.with_']) - tmpl = env.from_string('''\ - {% with a=42, b=23 -%} - {{ a }} = {{ b }} - {% endwith -%} - {{ a }} = {{ b }}\ - ''') - assert [x.strip() for x in tmpl.render(a=1, b=2).splitlines()] \ - == ['42 = 23', '1 = 2'] - - def test_extension_nodes(self): - env = Environment(extensions=[TestExtension]) - tmpl = env.from_string('{% test %}') - assert tmpl.render() == 'False|42|23|{}' - - def test_identifier(self): - assert TestExtension.identifier == __name__ + '.TestExtension' - - def test_rebinding(self): - original = Environment(extensions=[TestExtension]) - overlay = original.overlay() - for env in original, overlay: - for ext in itervalues(env.extensions): - assert ext.environment is env - - def test_preprocessor_extension(self): - env = Environment(extensions=[PreprocessorExtension]) - tmpl = env.from_string('{[[TEST]]}') - assert tmpl.render(foo=42) == '{(42)}' - - def test_streamfilter_extension(self): - env = Environment(extensions=[StreamFilterExtension]) - env.globals['gettext'] = lambda x: x.upper() - tmpl = env.from_string('Foo _(bar) Baz') - out = tmpl.render() - assert out == 'Foo BAR Baz' - - def test_extension_ordering(self): - class T1(Extension): - priority = 1 - - class T2(Extension): - priority = 2 - env = Environment(extensions=[T1, T2]) - ext = list(env.iter_extensions()) - assert ext[0].__class__ is T1 - assert ext[1].__class__ is T2 - - -@pytest.mark.ext -class TestInternationalization(): - - def test_trans(self): - tmpl = i18n_env.get_template('child.html') - assert tmpl.render(LANGUAGE='de') == 'fehlendpass auf' - - def test_trans_plural(self): - tmpl = i18n_env.get_template('plural.html') - assert tmpl.render(LANGUAGE='de', user_count=1) \ - == 'Ein Benutzer online' - assert tmpl.render(LANGUAGE='de', user_count=2) == '2 Benutzer online' - - def test_trans_plural_with_functions(self): - tmpl = i18n_env.get_template('plural2.html') - - def get_user_count(): - get_user_count.called += 1 - return 1 - get_user_count.called = 0 - assert tmpl.render(LANGUAGE='de', get_user_count=get_user_count) \ - == '1s' - assert get_user_count.called == 1 - - def test_complex_plural(self): - tmpl = i18n_env.from_string( - '{% trans foo=42, count=2 %}{{ count }} item{% ' - 'pluralize count %}{{ count }} items{% endtrans %}') - assert tmpl.render() == '2 items' - pytest.raises(TemplateAssertionError, i18n_env.from_string, - '{% trans foo %}...{% pluralize bar %}...{% endtrans %}') - - def test_trans_stringformatting(self): - tmpl = i18n_env.get_template('stringformat.html') - assert tmpl.render(LANGUAGE='de', user_count=5) == 'Benutzer: 5' - - def test_extract(self): - from jinja2.ext import babel_extract - source = BytesIO(''' - {{ gettext('Hello World') }} - {% trans %}Hello World{% endtrans %} - {% trans %}{{ users }} user{% pluralize %}{{ users }} users{% endtrans %} - '''.encode('ascii')) # make python 3 happy - assert list(babel_extract(source, - ('gettext', 'ngettext', '_'), [], {})) == [ - (2, 'gettext', u'Hello World', []), - (3, 'gettext', u'Hello World', []), - (4, 'ngettext', (u'%(users)s user', u'%(users)s users', None), []) - ] - - def test_comment_extract(self): - from jinja2.ext import babel_extract - source = BytesIO(''' - {# trans first #} - {{ gettext('Hello World') }} - {% trans %}Hello World{% endtrans %}{# trans second #} - {#: third #} - {% trans %}{{ users }} user{% pluralize %}{{ users }} users{% endtrans %} - '''.encode('utf-8')) # make python 3 happy - assert list(babel_extract(source, - ('gettext', 'ngettext', '_'), - ['trans', ':'], {})) == [ - (3, 'gettext', u'Hello World', ['first']), - (4, 'gettext', u'Hello World', ['second']), - (6, 'ngettext', (u'%(users)s user', u'%(users)s users', None), - ['third']) - ] - - -@pytest.mark.ext -class TestNewstyleInternationalization(): - - def test_trans(self): - tmpl = newstyle_i18n_env.get_template('child.html') - assert tmpl.render(LANGUAGE='de') == 'fehlendpass auf' - - def test_trans_plural(self): - tmpl = newstyle_i18n_env.get_template('plural.html') - assert tmpl.render(LANGUAGE='de', user_count=1) \ - == 'Ein Benutzer online' - assert tmpl.render(LANGUAGE='de', user_count=2) == '2 Benutzer online' - - def test_complex_plural(self): - tmpl = newstyle_i18n_env.from_string( - '{% trans foo=42, count=2 %}{{ count }} item{% ' - 'pluralize count %}{{ count }} items{% endtrans %}') - assert tmpl.render() == '2 items' - pytest.raises(TemplateAssertionError, i18n_env.from_string, - '{% trans foo %}...{% pluralize bar %}...{% endtrans %}') - - def test_trans_stringformatting(self): - tmpl = newstyle_i18n_env.get_template('stringformat.html') - assert tmpl.render(LANGUAGE='de', user_count=5) == 'Benutzer: 5' - - def test_newstyle_plural(self): - tmpl = newstyle_i18n_env.get_template('ngettext.html') - assert tmpl.render(LANGUAGE='de', apples=1) == '1 Apfel' - assert tmpl.render(LANGUAGE='de', apples=5) == u'5 Äpfel' - - def test_autoescape_support(self): - env = Environment(extensions=['jinja2.ext.autoescape', - 'jinja2.ext.i18n']) - env.install_gettext_callables( - lambda x: u'Wert: %(name)s', - lambda s, p, n: s, newstyle=True) - t = env.from_string('{% autoescape ae %}{{ gettext("foo", name=' - '"") }}{% endautoescape %}') - assert t.render(ae=True) == 'Wert: <test>' - assert t.render(ae=False) == 'Wert: ' - - def test_num_used_twice(self): - tmpl = newstyle_i18n_env.get_template('ngettext_long.html') - assert tmpl.render(apples=5, LANGUAGE='de') == u'5 Äpfel' - - def test_num_called_num(self): - source = newstyle_i18n_env.compile(''' - {% trans num=3 %}{{ num }} apple{% pluralize - %}{{ num }} apples{% endtrans %} - ''', raw=True) - # quite hacky, but the only way to properly test that. The idea is - # that the generated code does not pass num twice (although that - # would work) for better performance. This only works on the - # newstyle gettext of course - assert re.search(r"l_ngettext, u?'\%\(num\)s apple', u?'\%\(num\)s " - r"apples', 3", source) is not None - - def test_trans_vars(self): - t1 = newstyle_i18n_env.get_template('transvars1.html') - t2 = newstyle_i18n_env.get_template('transvars2.html') - t3 = newstyle_i18n_env.get_template('transvars3.html') - assert t1.render(num=1, LANGUAGE='de') == 'Benutzer: 1' - assert t2.render(count=23, LANGUAGE='de') == 'Benutzer: 23' - assert t3.render(num=42, LANGUAGE='de') == 'Benutzer: 42' - - def test_novars_vars_escaping(self): - t = newstyle_i18n_env.get_template('novars.html') - assert t.render() == '%(hello)s' - t = newstyle_i18n_env.get_template('vars.html') - assert t.render(foo='42') == '42%(foo)s' - t = newstyle_i18n_env.get_template('explicitvars.html') - assert t.render() == '%(foo)s' - - -@pytest.mark.ext -class TestAutoEscape(): - - def test_scoped_setting(self): - env = Environment(extensions=['jinja2.ext.autoescape'], - autoescape=True) - tmpl = env.from_string(''' - {{ "" }} - {% autoescape false %} - {{ "" }} - {% endautoescape %} - {{ "" }} - ''') - assert tmpl.render().split() == \ - [u'<HelloWorld>', u'', u'<HelloWorld>'] - - env = Environment(extensions=['jinja2.ext.autoescape'], - autoescape=False) - tmpl = env.from_string(''' - {{ "" }} - {% autoescape true %} - {{ "" }} - {% endautoescape %} - {{ "" }} - ''') - assert tmpl.render().split() == \ - [u'', u'<HelloWorld>', u''] - - def test_nonvolatile(self): - env = Environment(extensions=['jinja2.ext.autoescape'], - autoescape=True) - tmpl = env.from_string('{{ {"foo": ""}|xmlattr|escape }}') - assert tmpl.render() == ' foo="<test>"' - tmpl = env.from_string('{% autoescape false %}{{ {"foo": ""}' - '|xmlattr|escape }}{% endautoescape %}') - assert tmpl.render() == ' foo="&lt;test&gt;"' - - def test_volatile(self): - env = Environment(extensions=['jinja2.ext.autoescape'], - autoescape=True) - tmpl = env.from_string('{% autoescape foo %}{{ {"foo": ""}' - '|xmlattr|escape }}{% endautoescape %}') - assert tmpl.render(foo=False) == ' foo="&lt;test&gt;"' - assert tmpl.render(foo=True) == ' foo="<test>"' - - def test_scoping(self): - env = Environment(extensions=['jinja2.ext.autoescape']) - tmpl = env.from_string( - '{% autoescape true %}{% set x = "" %}{{ x }}' - '{% endautoescape %}{{ x }}{{ "" }}') - assert tmpl.render(x=1) == '<x>1' - - def test_volatile_scoping(self): - env = Environment(extensions=['jinja2.ext.autoescape']) - tmplsource = ''' - {% autoescape val %} - {% macro foo(x) %} - [{{ x }}] - {% endmacro %} - {{ foo().__class__.__name__ }} - {% endautoescape %} - {{ '' }} - ''' - tmpl = env.from_string(tmplsource) - assert tmpl.render(val=True).split()[0] == 'Markup' - assert tmpl.render(val=False).split()[0] == text_type.__name__ - - # looking at the source we should see there in raw - # (and then escaped as well) - env = Environment(extensions=['jinja2.ext.autoescape']) - pysource = env.compile(tmplsource, raw=True) - assert '\\n' in pysource - - env = Environment(extensions=['jinja2.ext.autoescape'], - autoescape=True) - pysource = env.compile(tmplsource, raw=True) - assert '<testing>\\n' in pysource diff --git a/deps/v8_inspector/third_party/jinja2/tests/test_filters.py b/deps/v8_inspector/third_party/jinja2/tests/test_filters.py deleted file mode 100644 index 741ef341b1b0f7..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/test_filters.py +++ /dev/null @@ -1,558 +0,0 @@ -# -*- coding: utf-8 -*- -""" - jinja2.testsuite.filters - ~~~~~~~~~~~~~~~~~~~~~~~~ - - Tests for the jinja filters. - - :copyright: (c) 2010 by the Jinja Team. - :license: BSD, see LICENSE for more details. -""" -import pytest -from jinja2 import Markup, Environment -from jinja2._compat import text_type, implements_to_string - - -@pytest.mark.filter -class TestFilter(): - - def test_filter_calling(self, env): - rv = env.call_filter('sum', [1, 2, 3]) - assert rv == 6 - - def test_capitalize(self, env): - tmpl = env.from_string('{{ "foo bar"|capitalize }}') - assert tmpl.render() == 'Foo bar' - - def test_center(self, env): - tmpl = env.from_string('{{ "foo"|center(9) }}') - assert tmpl.render() == ' foo ' - - def test_default(self, env): - tmpl = env.from_string( - "{{ missing|default('no') }}|{{ false|default('no') }}|" - "{{ false|default('no', true) }}|{{ given|default('no') }}" - ) - assert tmpl.render(given='yes') == 'no|False|no|yes' - - def test_dictsort(self, env): - tmpl = env.from_string( - '{{ foo|dictsort }}|' - '{{ foo|dictsort(true) }}|' - '{{ foo|dictsort(false, "value") }}' - ) - out = tmpl.render(foo={"aa": 0, "b": 1, "c": 2, "AB": 3}) - assert out == ("[('aa', 0), ('AB', 3), ('b', 1), ('c', 2)]|" - "[('AB', 3), ('aa', 0), ('b', 1), ('c', 2)]|" - "[('aa', 0), ('b', 1), ('c', 2), ('AB', 3)]") - - def test_batch(self, env): - tmpl = env.from_string("{{ foo|batch(3)|list }}|" - "{{ foo|batch(3, 'X')|list }}") - out = tmpl.render(foo=list(range(10))) - assert out == ("[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]|" - "[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 'X', 'X']]") - - def test_slice(self, env): - tmpl = env.from_string('{{ foo|slice(3)|list }}|' - '{{ foo|slice(3, "X")|list }}') - out = tmpl.render(foo=list(range(10))) - assert out == ("[[0, 1, 2, 3], [4, 5, 6], [7, 8, 9]]|" - "[[0, 1, 2, 3], [4, 5, 6, 'X'], [7, 8, 9, 'X']]") - - def test_escape(self, env): - tmpl = env.from_string('''{{ '<">&'|escape }}''') - out = tmpl.render() - assert out == '<">&' - - def test_striptags(self, env): - tmpl = env.from_string('''{{ foo|striptags }}''') - out = tmpl.render(foo='

just a small \n ' - 'example link

\n

to a webpage

' - '') - assert out == 'just a small example link to a webpage' - - def test_filesizeformat(self, env): - tmpl = env.from_string( - '{{ 100|filesizeformat }}|' - '{{ 1000|filesizeformat }}|' - '{{ 1000000|filesizeformat }}|' - '{{ 1000000000|filesizeformat }}|' - '{{ 1000000000000|filesizeformat }}|' - '{{ 100|filesizeformat(true) }}|' - '{{ 1000|filesizeformat(true) }}|' - '{{ 1000000|filesizeformat(true) }}|' - '{{ 1000000000|filesizeformat(true) }}|' - '{{ 1000000000000|filesizeformat(true) }}' - ) - out = tmpl.render() - assert out == ( - '100 Bytes|1.0 kB|1.0 MB|1.0 GB|1.0 TB|100 Bytes|' - '1000 Bytes|976.6 KiB|953.7 MiB|931.3 GiB' - ) - - def test_filesizeformat_issue59(self, env): - tmpl = env.from_string( - '{{ 300|filesizeformat }}|' - '{{ 3000|filesizeformat }}|' - '{{ 3000000|filesizeformat }}|' - '{{ 3000000000|filesizeformat }}|' - '{{ 3000000000000|filesizeformat }}|' - '{{ 300|filesizeformat(true) }}|' - '{{ 3000|filesizeformat(true) }}|' - '{{ 3000000|filesizeformat(true) }}' - ) - out = tmpl.render() - assert out == ( - '300 Bytes|3.0 kB|3.0 MB|3.0 GB|3.0 TB|300 Bytes|' - '2.9 KiB|2.9 MiB' - ) - - def test_first(self, env): - tmpl = env.from_string('{{ foo|first }}') - out = tmpl.render(foo=list(range(10))) - assert out == '0' - - def test_float(self, env): - tmpl = env.from_string('{{ "42"|float }}|' - '{{ "ajsghasjgd"|float }}|' - '{{ "32.32"|float }}') - out = tmpl.render() - assert out == '42.0|0.0|32.32' - - def test_format(self, env): - tmpl = env.from_string('''{{ "%s|%s"|format("a", "b") }}''') - out = tmpl.render() - assert out == 'a|b' - - def test_indent(self, env): - tmpl = env.from_string('{{ foo|indent(2) }}|{{ foo|indent(2, true) }}') - text = '\n'.join([' '.join(['foo', 'bar'] * 2)] * 2) - out = tmpl.render(foo=text) - assert out == ('foo bar foo bar\n foo bar foo bar| ' - 'foo bar foo bar\n foo bar foo bar') - - def test_int(self, env): - tmpl = env.from_string('{{ "42"|int }}|{{ "ajsghasjgd"|int }}|' - '{{ "32.32"|int }}|{{ "0x4d32"|int(0, 16) }}|' - '{{ "011"|int(0, 8)}}|{{ "0x33FU"|int(0, 16) }}') - out = tmpl.render() - assert out == '42|0|32|19762|9|0' - - def test_join(self, env): - tmpl = env.from_string('{{ [1, 2, 3]|join("|") }}') - out = tmpl.render() - assert out == '1|2|3' - - env2 = Environment(autoescape=True) - tmpl = env2.from_string( - '{{ ["", "foo"|safe]|join }}') - assert tmpl.render() == '<foo>foo' - - def test_join_attribute(self, env): - class User(object): - def __init__(self, username): - self.username = username - tmpl = env.from_string('''{{ users|join(', ', 'username') }}''') - assert tmpl.render(users=map(User, ['foo', 'bar'])) == 'foo, bar' - - def test_last(self, env): - tmpl = env.from_string('''{{ foo|last }}''') - out = tmpl.render(foo=list(range(10))) - assert out == '9' - - def test_length(self, env): - tmpl = env.from_string('''{{ "hello world"|length }}''') - out = tmpl.render() - assert out == '11' - - def test_lower(self, env): - tmpl = env.from_string('''{{ "FOO"|lower }}''') - out = tmpl.render() - assert out == 'foo' - - def test_pprint(self, env): - from pprint import pformat - tmpl = env.from_string('''{{ data|pprint }}''') - data = list(range(1000)) - assert tmpl.render(data=data) == pformat(data) - - def test_random(self, env): - tmpl = env.from_string('''{{ seq|random }}''') - seq = list(range(100)) - for _ in range(10): - assert int(tmpl.render(seq=seq)) in seq - - def test_reverse(self, env): - tmpl = env.from_string('{{ "foobar"|reverse|join }}|' - '{{ [1, 2, 3]|reverse|list }}') - assert tmpl.render() == 'raboof|[3, 2, 1]' - - def test_string(self, env): - x = [1, 2, 3, 4, 5] - tmpl = env.from_string('''{{ obj|string }}''') - assert tmpl.render(obj=x) == text_type(x) - - def test_title(self, env): - tmpl = env.from_string('''{{ "foo bar"|title }}''') - assert tmpl.render() == "Foo Bar" - tmpl = env.from_string('''{{ "foo's bar"|title }}''') - assert tmpl.render() == "Foo's Bar" - tmpl = env.from_string('''{{ "foo bar"|title }}''') - assert tmpl.render() == "Foo Bar" - tmpl = env.from_string('''{{ "f bar f"|title }}''') - assert tmpl.render() == "F Bar F" - tmpl = env.from_string('''{{ "foo-bar"|title }}''') - assert tmpl.render() == "Foo-Bar" - tmpl = env.from_string('''{{ "foo\tbar"|title }}''') - assert tmpl.render() == "Foo\tBar" - tmpl = env.from_string('''{{ "FOO\tBAR"|title }}''') - assert tmpl.render() == "Foo\tBar" - - class Foo: - def __str__(self): - return 'foo-bar' - - tmpl = env.from_string('''{{ data|title }}''') - out = tmpl.render(data=Foo()) - assert out == 'Foo-Bar' - - def test_truncate(self, env): - tmpl = env.from_string( - '{{ data|truncate(15, true, ">>>") }}|' - '{{ data|truncate(15, false, ">>>") }}|' - '{{ smalldata|truncate(15) }}' - ) - out = tmpl.render(data='foobar baz bar' * 1000, - smalldata='foobar baz bar') - msg = 'Current output: %s' % out - assert out == 'foobar baz b>>>|foobar baz >>>|foobar baz bar', msg - - def test_truncate_very_short(self, env): - tmpl = env.from_string( - '{{ "foo bar baz"|truncate(9) }}|' - '{{ "foo bar baz"|truncate(9, true) }}' - ) - out = tmpl.render() - assert out == 'foo ...|foo ba...', out - - def test_truncate_end_length(self, env): - tmpl = env.from_string('{{ "Joel is a slug"|truncate(9, true) }}') - out = tmpl.render() - assert out == 'Joel i...', 'Current output: %s' % out - - def test_upper(self, env): - tmpl = env.from_string('{{ "foo"|upper }}') - assert tmpl.render() == 'FOO' - - def test_urlize(self, env): - tmpl = env.from_string( - '{{ "foo http://www.example.com/ bar"|urlize }}') - assert tmpl.render() == 'foo '\ - 'http://www.example.com/ bar' - - def test_urlize_target_parameter(self, env): - tmpl = env.from_string( - '{{ "foo http://www.example.com/ bar"|urlize(target="_blank") }}' - ) - assert tmpl.render() \ - == 'foo '\ - 'http://www.example.com/ bar' - tmpl = env.from_string( - '{{ "foo http://www.example.com/ bar"|urlize(target=42) }}' - ) - assert tmpl.render() == 'foo '\ - 'http://www.example.com/ bar' - - def test_wordcount(self, env): - tmpl = env.from_string('{{ "foo bar baz"|wordcount }}') - assert tmpl.render() == '3' - - def test_block(self, env): - tmpl = env.from_string( - '{% filter lower|escape %}{% endfilter %}' - ) - assert tmpl.render() == '<hehe>' - - def test_chaining(self, env): - tmpl = env.from_string( - '''{{ ['', '']|first|upper|escape }}''' - ) - assert tmpl.render() == '<FOO>' - - def test_sum(self, env): - tmpl = env.from_string('''{{ [1, 2, 3, 4, 5, 6]|sum }}''') - assert tmpl.render() == '21' - - def test_sum_attributes(self, env): - tmpl = env.from_string('''{{ values|sum('value') }}''') - assert tmpl.render(values=[ - {'value': 23}, - {'value': 1}, - {'value': 18}, - ]) == '42' - - def test_sum_attributes_nested(self, env): - tmpl = env.from_string('''{{ values|sum('real.value') }}''') - assert tmpl.render(values=[ - {'real': {'value': 23}}, - {'real': {'value': 1}}, - {'real': {'value': 18}}, - ]) == '42' - - def test_sum_attributes_tuple(self, env): - tmpl = env.from_string('''{{ values.items()|sum('1') }}''') - assert tmpl.render(values={ - 'foo': 23, - 'bar': 1, - 'baz': 18, - }) == '42' - - def test_abs(self, env): - tmpl = env.from_string('''{{ -1|abs }}|{{ 1|abs }}''') - assert tmpl.render() == '1|1', tmpl.render() - - def test_round_positive(self, env): - tmpl = env.from_string('{{ 2.7|round }}|{{ 2.1|round }}|' - "{{ 2.1234|round(3, 'floor') }}|" - "{{ 2.1|round(0, 'ceil') }}") - assert tmpl.render() == '3.0|2.0|2.123|3.0', tmpl.render() - - def test_round_negative(self, env): - tmpl = env.from_string('{{ 21.3|round(-1)}}|' - "{{ 21.3|round(-1, 'ceil')}}|" - "{{ 21.3|round(-1, 'floor')}}") - assert tmpl.render() == '20.0|30.0|20.0', tmpl.render() - - def test_xmlattr(self, env): - tmpl = env.from_string( - "{{ {'foo': 42, 'bar': 23, 'fish': none, " - "'spam': missing, 'blub:blub': ''}|xmlattr }}") - out = tmpl.render().split() - assert len(out) == 3 - assert 'foo="42"' in out - assert 'bar="23"' in out - assert 'blub:blub="<?>"' in out - - def test_sort1(self, env): - tmpl = env.from_string( - '{{ [2, 3, 1]|sort }}|{{ [2, 3, 1]|sort(true) }}') - assert tmpl.render() == '[1, 2, 3]|[3, 2, 1]' - - def test_sort2(self, env): - tmpl = env.from_string('{{ "".join(["c", "A", "b", "D"]|sort) }}') - assert tmpl.render() == 'AbcD' - - def test_sort3(self, env): - tmpl = env.from_string('''{{ ['foo', 'Bar', 'blah']|sort }}''') - assert tmpl.render() == "['Bar', 'blah', 'foo']" - - def test_sort4(self, env): - @implements_to_string - class Magic(object): - def __init__(self, value): - self.value = value - - def __str__(self): - return text_type(self.value) - tmpl = env.from_string('''{{ items|sort(attribute='value')|join }}''') - assert tmpl.render(items=map(Magic, [3, 2, 4, 1])) == '1234' - - def test_groupby(self, env): - tmpl = env.from_string(''' - {%- for grouper, list in [{'foo': 1, 'bar': 2}, - {'foo': 2, 'bar': 3}, - {'foo': 1, 'bar': 1}, - {'foo': 3, 'bar': 4}]|groupby('foo') -%} - {{ grouper }}{% for x in list %}: {{ x.foo }}, {{ x.bar }}{% endfor %}| - {%- endfor %}''') - assert tmpl.render().split('|') == [ - "1: 1, 2: 1, 1", - "2: 2, 3", - "3: 3, 4", - "" - ] - - def test_groupby_tuple_index(self, env): - tmpl = env.from_string(''' - {%- for grouper, list in [('a', 1), ('a', 2), ('b', 1)]|groupby(0) -%} - {{ grouper }}{% for x in list %}:{{ x.1 }}{% endfor %}| - {%- endfor %}''') - assert tmpl.render() == 'a:1:2|b:1|' - - def test_groupby_multidot(self, env): - class Date(object): - def __init__(self, day, month, year): - self.day = day - self.month = month - self.year = year - - class Article(object): - def __init__(self, title, *date): - self.date = Date(*date) - self.title = title - articles = [ - Article('aha', 1, 1, 1970), - Article('interesting', 2, 1, 1970), - Article('really?', 3, 1, 1970), - Article('totally not', 1, 1, 1971) - ] - tmpl = env.from_string(''' - {%- for year, list in articles|groupby('date.year') -%} - {{ year }}{% for x in list %}[{{ x.title }}]{% endfor %}| - {%- endfor %}''') - assert tmpl.render(articles=articles).split('|') == [ - '1970[aha][interesting][really?]', - '1971[totally not]', - '' - ] - - def test_filtertag(self, env): - tmpl = env.from_string("{% filter upper|replace('FOO', 'foo') %}" - "foobar{% endfilter %}") - assert tmpl.render() == 'fooBAR' - - def test_replace(self, env): - env = Environment() - tmpl = env.from_string('{{ string|replace("o", 42) }}') - assert tmpl.render(string='') == '' - env = Environment(autoescape=True) - tmpl = env.from_string('{{ string|replace("o", 42) }}') - assert tmpl.render(string='') == '<f4242>' - tmpl = env.from_string('{{ string|replace("<", 42) }}') - assert tmpl.render(string='') == '42foo>' - tmpl = env.from_string('{{ string|replace("o", ">x<") }}') - assert tmpl.render(string=Markup('foo')) == 'f>x<>x<' - - def test_forceescape(self, env): - tmpl = env.from_string('{{ x|forceescape }}') - assert tmpl.render(x=Markup('
')) == u'<div />' - - def test_safe(self, env): - env = Environment(autoescape=True) - tmpl = env.from_string('{{ "
foo
"|safe }}') - assert tmpl.render() == '
foo
' - tmpl = env.from_string('{{ "
foo
" }}') - assert tmpl.render() == '<div>foo</div>' - - def test_urlencode(self, env): - env = Environment(autoescape=True) - tmpl = env.from_string('{{ "Hello, world!"|urlencode }}') - assert tmpl.render() == 'Hello%2C%20world%21' - tmpl = env.from_string('{{ o|urlencode }}') - assert tmpl.render(o=u"Hello, world\u203d") \ - == "Hello%2C%20world%E2%80%BD" - assert tmpl.render(o=(("f", 1),)) == "f=1" - assert tmpl.render(o=(('f', 1), ("z", 2))) == "f=1&z=2" - assert tmpl.render(o=((u"\u203d", 1),)) == "%E2%80%BD=1" - assert tmpl.render(o={u"\u203d": 1}) == "%E2%80%BD=1" - assert tmpl.render(o={0: 1}) == "0=1" - - def test_simple_map(self, env): - env = Environment() - tmpl = env.from_string('{{ ["1", "2", "3"]|map("int")|sum }}') - assert tmpl.render() == '6' - - def test_attribute_map(self, env): - class User(object): - def __init__(self, name): - self.name = name - env = Environment() - users = [ - User('john'), - User('jane'), - User('mike'), - ] - tmpl = env.from_string('{{ users|map(attribute="name")|join("|") }}') - assert tmpl.render(users=users) == 'john|jane|mike' - - def test_empty_map(self, env): - env = Environment() - tmpl = env.from_string('{{ none|map("upper")|list }}') - assert tmpl.render() == '[]' - - def test_simple_select(self, env): - env = Environment() - tmpl = env.from_string('{{ [1, 2, 3, 4, 5]|select("odd")|join("|") }}') - assert tmpl.render() == '1|3|5' - - def test_bool_select(self, env): - env = Environment() - tmpl = env.from_string( - '{{ [none, false, 0, 1, 2, 3, 4, 5]|select|join("|") }}' - ) - assert tmpl.render() == '1|2|3|4|5' - - def test_simple_reject(self, env): - env = Environment() - tmpl = env.from_string('{{ [1, 2, 3, 4, 5]|reject("odd")|join("|") }}') - assert tmpl.render() == '2|4' - - def test_bool_reject(self, env): - env = Environment() - tmpl = env.from_string( - '{{ [none, false, 0, 1, 2, 3, 4, 5]|reject|join("|") }}' - ) - assert tmpl.render() == 'None|False|0' - - def test_simple_select_attr(self, env): - class User(object): - def __init__(self, name, is_active): - self.name = name - self.is_active = is_active - env = Environment() - users = [ - User('john', True), - User('jane', True), - User('mike', False), - ] - tmpl = env.from_string( - '{{ users|selectattr("is_active")|' - 'map(attribute="name")|join("|") }}' - ) - assert tmpl.render(users=users) == 'john|jane' - - def test_simple_reject_attr(self, env): - class User(object): - def __init__(self, name, is_active): - self.name = name - self.is_active = is_active - env = Environment() - users = [ - User('john', True), - User('jane', True), - User('mike', False), - ] - tmpl = env.from_string('{{ users|rejectattr("is_active")|' - 'map(attribute="name")|join("|") }}') - assert tmpl.render(users=users) == 'mike' - - def test_func_select_attr(self, env): - class User(object): - def __init__(self, id, name): - self.id = id - self.name = name - env = Environment() - users = [ - User(1, 'john'), - User(2, 'jane'), - User(3, 'mike'), - ] - tmpl = env.from_string('{{ users|selectattr("id", "odd")|' - 'map(attribute="name")|join("|") }}') - assert tmpl.render(users=users) == 'john|mike' - - def test_func_reject_attr(self, env): - class User(object): - def __init__(self, id, name): - self.id = id - self.name = name - env = Environment() - users = [ - User(1, 'john'), - User(2, 'jane'), - User(3, 'mike'), - ] - tmpl = env.from_string('{{ users|rejectattr("id", "odd")|' - 'map(attribute="name")|join("|") }}') - assert tmpl.render(users=users) == 'jane' diff --git a/deps/v8_inspector/third_party/jinja2/tests/test_imports.py b/deps/v8_inspector/third_party/jinja2/tests/test_imports.py deleted file mode 100644 index 643c995c6e6ade..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/test_imports.py +++ /dev/null @@ -1,148 +0,0 @@ -# -*- coding: utf-8 -*- -""" - jinja2.testsuite.imports - ~~~~~~~~~~~~~~~~~~~~~~~~ - - Tests the import features (with includes). - - :copyright: (c) 2010 by the Jinja Team. - :license: BSD, see LICENSE for more details. -""" -import pytest - -from jinja2 import Environment, DictLoader -from jinja2.exceptions import TemplateNotFound, TemplatesNotFound - - -@pytest.fixture -def test_env(): - env = Environment(loader=DictLoader(dict( - module='{% macro test() %}[{{ foo }}|{{ bar }}]{% endmacro %}', - header='[{{ foo }}|{{ 23 }}]', - o_printer='({{ o }})' - ))) - env.globals['bar'] = 23 - return env - - -@pytest.mark.imports -class TestImports(): - - def test_context_imports(self, test_env): - t = test_env.from_string('{% import "module" as m %}{{ m.test() }}') - assert t.render(foo=42) == '[|23]' - t = test_env.from_string( - '{% import "module" as m without context %}{{ m.test() }}' - ) - assert t.render(foo=42) == '[|23]' - t = test_env.from_string( - '{% import "module" as m with context %}{{ m.test() }}' - ) - assert t.render(foo=42) == '[42|23]' - t = test_env.from_string('{% from "module" import test %}{{ test() }}') - assert t.render(foo=42) == '[|23]' - t = test_env.from_string( - '{% from "module" import test without context %}{{ test() }}' - ) - assert t.render(foo=42) == '[|23]' - t = test_env.from_string( - '{% from "module" import test with context %}{{ test() }}' - ) - assert t.render(foo=42) == '[42|23]' - - def test_trailing_comma(self, test_env): - test_env.from_string('{% from "foo" import bar, baz with context %}') - test_env.from_string('{% from "foo" import bar, baz, with context %}') - test_env.from_string('{% from "foo" import bar, with context %}') - test_env.from_string('{% from "foo" import bar, with, context %}') - test_env.from_string('{% from "foo" import bar, with with context %}') - - def test_exports(self, test_env): - m = test_env.from_string(''' - {% macro toplevel() %}...{% endmacro %} - {% macro __private() %}...{% endmacro %} - {% set variable = 42 %} - {% for item in [1] %} - {% macro notthere() %}{% endmacro %} - {% endfor %} - ''').module - assert m.toplevel() == '...' - assert not hasattr(m, '__missing') - assert m.variable == 42 - assert not hasattr(m, 'notthere') - - -@pytest.mark.imports -@pytest.mark.includes -class TestIncludes(): - - def test_context_include(self, test_env): - t = test_env.from_string('{% include "header" %}') - assert t.render(foo=42) == '[42|23]' - t = test_env.from_string('{% include "header" with context %}') - assert t.render(foo=42) == '[42|23]' - t = test_env.from_string('{% include "header" without context %}') - assert t.render(foo=42) == '[|23]' - - def test_choice_includes(self, test_env): - t = test_env.from_string('{% include ["missing", "header"] %}') - assert t.render(foo=42) == '[42|23]' - - t = test_env.from_string( - '{% include ["missing", "missing2"] ignore missing %}' - ) - assert t.render(foo=42) == '' - - t = test_env.from_string('{% include ["missing", "missing2"] %}') - pytest.raises(TemplateNotFound, t.render) - try: - t.render() - except TemplatesNotFound as e: - assert e.templates == ['missing', 'missing2'] - assert e.name == 'missing2' - else: - assert False, 'thou shalt raise' - - def test_includes(t, **ctx): - ctx['foo'] = 42 - assert t.render(ctx) == '[42|23]' - - t = test_env.from_string('{% include ["missing", "header"] %}') - test_includes(t) - t = test_env.from_string('{% include x %}') - test_includes(t, x=['missing', 'header']) - t = test_env.from_string('{% include [x, "header"] %}') - test_includes(t, x='missing') - t = test_env.from_string('{% include x %}') - test_includes(t, x='header') - t = test_env.from_string('{% include x %}') - test_includes(t, x='header') - t = test_env.from_string('{% include [x] %}') - test_includes(t, x='header') - - def test_include_ignoring_missing(self, test_env): - t = test_env.from_string('{% include "missing" %}') - pytest.raises(TemplateNotFound, t.render) - for extra in '', 'with context', 'without context': - t = test_env.from_string('{% include "missing" ignore missing ' + - extra + ' %}') - assert t.render() == '' - - def test_context_include_with_overrides(self, test_env): - env = Environment(loader=DictLoader(dict( - main="{% for item in [1, 2, 3] %}{% include 'item' %}{% endfor %}", - item="{{ item }}" - ))) - assert env.get_template("main").render() == "123" - - def test_unoptimized_scopes(self, test_env): - t = test_env.from_string(""" - {% macro outer(o) %} - {% macro inner() %} - {% include "o_printer" %} - {% endmacro %} - {{ inner() }} - {% endmacro %} - {{ outer("FOO") }} - """) - assert t.render().strip() == '(FOO)' diff --git a/deps/v8_inspector/third_party/jinja2/tests/test_inheritance.py b/deps/v8_inspector/third_party/jinja2/tests/test_inheritance.py deleted file mode 100644 index 1cb7390441c09e..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/test_inheritance.py +++ /dev/null @@ -1,248 +0,0 @@ -# -*- coding: utf-8 -*- -""" - jinja2.testsuite.inheritance - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - Tests the template inheritance feature. - - :copyright: (c) 2010 by the Jinja Team. - :license: BSD, see LICENSE for more details. -""" -import pytest - -from jinja2 import Environment, DictLoader, TemplateError - - -LAYOUTTEMPLATE = '''\ -|{% block block1 %}block 1 from layout{% endblock %} -|{% block block2 %}block 2 from layout{% endblock %} -|{% block block3 %} -{% block block4 %}nested block 4 from layout{% endblock %} -{% endblock %}|''' - -LEVEL1TEMPLATE = '''\ -{% extends "layout" %} -{% block block1 %}block 1 from level1{% endblock %}''' - -LEVEL2TEMPLATE = '''\ -{% extends "level1" %} -{% block block2 %}{% block block5 %}nested block 5 from level2{% -endblock %}{% endblock %}''' - -LEVEL3TEMPLATE = '''\ -{% extends "level2" %} -{% block block5 %}block 5 from level3{% endblock %} -{% block block4 %}block 4 from level3{% endblock %} -''' - -LEVEL4TEMPLATE = '''\ -{% extends "level3" %} -{% block block3 %}block 3 from level4{% endblock %} -''' - -WORKINGTEMPLATE = '''\ -{% extends "layout" %} -{% block block1 %} - {% if false %} - {% block block2 %} - this should workd - {% endblock %} - {% endif %} -{% endblock %} -''' - -DOUBLEEXTENDS = '''\ -{% extends "layout" %} -{% extends "layout" %} -{% block block1 %} - {% if false %} - {% block block2 %} - this should workd - {% endblock %} - {% endif %} -{% endblock %} -''' - - -@pytest.fixture -def env(): - return Environment(loader=DictLoader({ - 'layout': LAYOUTTEMPLATE, - 'level1': LEVEL1TEMPLATE, - 'level2': LEVEL2TEMPLATE, - 'level3': LEVEL3TEMPLATE, - 'level4': LEVEL4TEMPLATE, - 'working': WORKINGTEMPLATE, - 'doublee': DOUBLEEXTENDS, - }), trim_blocks=True) - - -@pytest.mark.inheritance -class TestInheritance(): - - def test_layout(self, env): - tmpl = env.get_template('layout') - assert tmpl.render() == ('|block 1 from layout|block 2 from ' - 'layout|nested block 4 from layout|') - - def test_level1(self, env): - tmpl = env.get_template('level1') - assert tmpl.render() == ('|block 1 from level1|block 2 from ' - 'layout|nested block 4 from layout|') - - def test_level2(self, env): - tmpl = env.get_template('level2') - assert tmpl.render() == ('|block 1 from level1|nested block 5 from ' - 'level2|nested block 4 from layout|') - - def test_level3(self, env): - tmpl = env.get_template('level3') - assert tmpl.render() == ('|block 1 from level1|block 5 from level3|' - 'block 4 from level3|') - - def test_level4(self, env): - tmpl = env.get_template('level4') - assert tmpl.render() == ('|block 1 from level1|block 5 from ' - 'level3|block 3 from level4|') - - def test_super(self, env): - env = Environment(loader=DictLoader({ - 'a': '{% block intro %}INTRO{% endblock %}|' - 'BEFORE|{% block data %}INNER{% endblock %}|AFTER', - 'b': '{% extends "a" %}{% block data %}({{ ' - 'super() }}){% endblock %}', - 'c': '{% extends "b" %}{% block intro %}--{{ ' - 'super() }}--{% endblock %}\n{% block data ' - '%}[{{ super() }}]{% endblock %}' - })) - tmpl = env.get_template('c') - assert tmpl.render() == '--INTRO--|BEFORE|[(INNER)]|AFTER' - - def test_working(self, env): - tmpl = env.get_template('working') - - def test_reuse_blocks(self, env): - tmpl = env.from_string('{{ self.foo() }}|{% block foo %}42' - '{% endblock %}|{{ self.foo() }}') - assert tmpl.render() == '42|42|42' - - def test_preserve_blocks(self, env): - env = Environment(loader=DictLoader({ - 'a': '{% if false %}{% block x %}A{% endblock %}' - '{% endif %}{{ self.x() }}', - 'b': '{% extends "a" %}{% block x %}B{{ super() }}{% endblock %}' - })) - tmpl = env.get_template('b') - assert tmpl.render() == 'BA' - - def test_dynamic_inheritance(self, env): - env = Environment(loader=DictLoader({ - 'master1': 'MASTER1{% block x %}{% endblock %}', - 'master2': 'MASTER2{% block x %}{% endblock %}', - 'child': '{% extends master %}{% block x %}CHILD{% endblock %}' - })) - tmpl = env.get_template('child') - for m in range(1, 3): - assert tmpl.render(master='master%d' % m) == 'MASTER%dCHILD' % m - - def test_multi_inheritance(self, env): - env = Environment(loader=DictLoader({ - 'master1': 'MASTER1{% block x %}{% endblock %}', - 'master2': 'MASTER2{% block x %}{% endblock %}', - 'child': - '''{% if master %}{% extends master %}{% else %}{% extends - 'master1' %}{% endif %}{% block x %}CHILD{% endblock %}''' - })) - tmpl = env.get_template('child') - assert tmpl.render(master='master2') == 'MASTER2CHILD' - assert tmpl.render(master='master1') == 'MASTER1CHILD' - assert tmpl.render() == 'MASTER1CHILD' - - def test_scoped_block(self, env): - env = Environment(loader=DictLoader({ - 'master.html': '{% for item in seq %}[{% block item scoped %}' - '{% endblock %}]{% endfor %}' - })) - t = env.from_string('{% extends "master.html" %}{% block item %}' - '{{ item }}{% endblock %}') - assert t.render(seq=list(range(5))) == '[0][1][2][3][4]' - - def test_super_in_scoped_block(self, env): - env = Environment(loader=DictLoader({ - 'master.html': '{% for item in seq %}[{% block item scoped %}' - '{{ item }}{% endblock %}]{% endfor %}' - })) - t = env.from_string('{% extends "master.html" %}{% block item %}' - '{{ super() }}|{{ item * 2 }}{% endblock %}') - assert t.render(seq=list(range(5))) == '[0|0][1|2][2|4][3|6][4|8]' - - def test_scoped_block_after_inheritance(self, env): - env = Environment(loader=DictLoader({ - 'layout.html': ''' - {% block useless %}{% endblock %} - ''', - 'index.html': ''' - {%- extends 'layout.html' %} - {% from 'helpers.html' import foo with context %} - {% block useless %} - {% for x in [1, 2, 3] %} - {% block testing scoped %} - {{ foo(x) }} - {% endblock %} - {% endfor %} - {% endblock %} - ''', - 'helpers.html': ''' - {% macro foo(x) %}{{ the_foo + x }}{% endmacro %} - ''' - })) - rv = env.get_template('index.html').render(the_foo=42).split() - assert rv == ['43', '44', '45'] - - -@pytest.mark.inheritance -class TestBugFix(): - - def test_fixed_macro_scoping_bug(self, env): - assert Environment(loader=DictLoader({ - 'test.html': '''\ - {% extends 'details.html' %} - - {% macro my_macro() %} - my_macro - {% endmacro %} - - {% block inner_box %} - {{ my_macro() }} - {% endblock %} - ''', - 'details.html': '''\ - {% extends 'standard.html' %} - - {% macro my_macro() %} - my_macro - {% endmacro %} - - {% block content %} - {% block outer_box %} - outer_box - {% block inner_box %} - inner_box - {% endblock %} - {% endblock %} - {% endblock %} - ''', - 'standard.html': ''' - {% block content %} {% endblock %} - ''' - })).get_template("test.html").render().split() \ - == [u'outer_box', u'my_macro'] - - def test_double_extends(self, env): - """Ensures that a template with more than 1 {% extends ... %} usage - raises a ``TemplateError``. - """ - try: - tmpl = env.get_template('doublee') - except Exception as e: - assert isinstance(e, TemplateError) diff --git a/deps/v8_inspector/third_party/jinja2/tests/test_lexnparse.py b/deps/v8_inspector/third_party/jinja2/tests/test_lexnparse.py deleted file mode 100644 index ff334bf0ca8b08..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/test_lexnparse.py +++ /dev/null @@ -1,609 +0,0 @@ -# -*- coding: utf-8 -*- -""" - jinja2.testsuite.lexnparse - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - - All the unittests regarding lexing, parsing and syntax. - - :copyright: (c) 2010 by the Jinja Team. - :license: BSD, see LICENSE for more details. -""" -import pytest - -from jinja2 import Environment, Template, TemplateSyntaxError, \ - UndefinedError, nodes -from jinja2._compat import iteritems, text_type, PY2 -from jinja2.lexer import Token, TokenStream, TOKEN_EOF, \ - TOKEN_BLOCK_BEGIN, TOKEN_BLOCK_END - - -# how does a string look like in jinja syntax? -if PY2: - def jinja_string_repr(string): - return repr(string)[1:] -else: - jinja_string_repr = repr - - -@pytest.mark.lexnparse -@pytest.mark.tokenstream -class TestTokenStream(): - test_tokens = [Token(1, TOKEN_BLOCK_BEGIN, ''), - Token(2, TOKEN_BLOCK_END, ''), - ] - - def test_simple(self, env): - ts = TokenStream(self.test_tokens, "foo", "bar") - assert ts.current.type is TOKEN_BLOCK_BEGIN - assert bool(ts) - assert not bool(ts.eos) - next(ts) - assert ts.current.type is TOKEN_BLOCK_END - assert bool(ts) - assert not bool(ts.eos) - next(ts) - assert ts.current.type is TOKEN_EOF - assert not bool(ts) - assert bool(ts.eos) - - def test_iter(self, env): - token_types = [ - t.type for t in TokenStream(self.test_tokens, "foo", "bar") - ] - assert token_types == ['block_begin', 'block_end', ] - - -@pytest.mark.lexnparse -@pytest.mark.lexer -class TestLexer(): - - def test_raw1(self, env): - tmpl = env.from_string( - '{% raw %}foo{% endraw %}|' - '{%raw%}{{ bar }}|{% baz %}{% endraw %}') - assert tmpl.render() == 'foo|{{ bar }}|{% baz %}' - - def test_raw2(self, env): - tmpl = env.from_string('1 {%- raw -%} 2 {%- endraw -%} 3') - assert tmpl.render() == '123' - - def test_balancing(self, env): - env = Environment('{%', '%}', '${', '}') - tmpl = env.from_string('''{% for item in seq - %}${{'foo': item}|upper}{% endfor %}''') - assert tmpl.render(seq=list(range(3))) \ - == "{'FOO': 0}{'FOO': 1}{'FOO': 2}" - - def test_comments(self, env): - env = Environment('', '{', '}') - tmpl = env.from_string('''\ -
    - -
  • {item}
  • - -
''') - assert tmpl.render(seq=list(range(3))) \ - == ("
    \n
  • 0
  • \n ""
  • 1
  • \n
  • 2
  • \n
") - - def test_string_escapes(self, env): - for char in u'\0', u'\u2668', u'\xe4', u'\t', u'\r', u'\n': - tmpl = env.from_string('{{ %s }}' % jinja_string_repr(char)) - assert tmpl.render() == char - assert env.from_string('{{ "\N{HOT SPRINGS}" }}').render() == u'\u2668' - - def test_bytefallback(self, env): - from pprint import pformat - tmpl = env.from_string(u'''{{ 'foo'|pprint }}|{{ 'bär'|pprint }}''') - assert tmpl.render() == pformat('foo') + '|' + pformat(u'bär') - - def test_operators(self, env): - from jinja2.lexer import operators - for test, expect in iteritems(operators): - if test in '([{}])': - continue - stream = env.lexer.tokenize('{{ %s }}' % test) - next(stream) - assert stream.current.type == expect - - def test_normalizing(self, env): - for seq in '\r', '\r\n', '\n': - env = Environment(newline_sequence=seq) - tmpl = env.from_string('1\n2\r\n3\n4\n') - result = tmpl.render() - assert result.replace(seq, 'X') == '1X2X3X4' - - def test_trailing_newline(self, env): - for keep in [True, False]: - env = Environment(keep_trailing_newline=keep) - for template, expected in [ - ('', {}), - ('no\nnewline', {}), - ('with\nnewline\n', {False: 'with\nnewline'}), - ('with\nseveral\n\n\n', {False: 'with\nseveral\n\n'}), - ]: - tmpl = env.from_string(template) - expect = expected.get(keep, template) - result = tmpl.render() - assert result == expect, (keep, template, result, expect) - - -@pytest.mark.lexnparse -@pytest.mark.parser -class TestParser(): - - def test_php_syntax(self, env): - env = Environment('', '', '') - tmpl = env.from_string('''\ -\ - - -''') - assert tmpl.render(seq=list(range(5))) == '01234' - - def test_erb_syntax(self, env): - env = Environment('<%', '%>', '<%=', '%>', '<%#', '%>') - tmpl = env.from_string('''\ -<%# I'm a comment, I'm not interesting %>\ -<% for item in seq -%> - <%= item %> -<%- endfor %>''') - assert tmpl.render(seq=list(range(5))) == '01234' - - def test_comment_syntax(self, env): - env = Environment('', '${', '}', '') - tmpl = env.from_string('''\ -\ - - ${item} -''') - assert tmpl.render(seq=list(range(5))) == '01234' - - def test_balancing(self, env): - tmpl = env.from_string('''{{{'foo':'bar'}.foo}}''') - assert tmpl.render() == 'bar' - - def test_start_comment(self, env): - tmpl = env.from_string('''{# foo comment -and bar comment #} -{% macro blub() %}foo{% endmacro %} -{{ blub() }}''') - assert tmpl.render().strip() == 'foo' - - def test_line_syntax(self, env): - env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%') - tmpl = env.from_string('''\ -<%# regular comment %> -% for item in seq: - ${item} -% endfor''') - assert [ - int(x.strip()) for x in tmpl.render(seq=list(range(5))).split() - ] == list(range(5)) - - env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##') - tmpl = env.from_string('''\ -<%# regular comment %> -% for item in seq: - ${item} ## the rest of the stuff -% endfor''') - assert [ - int(x.strip()) for x in tmpl.render(seq=list(range(5))).split() - ] == list(range(5)) - - def test_line_syntax_priority(self, env): - # XXX: why is the whitespace there in front of the newline? - env = Environment('{%', '%}', '${', '}', '/*', '*/', '##', '#') - tmpl = env.from_string('''\ -/* ignore me. - I'm a multiline comment */ -## for item in seq: -* ${item} # this is just extra stuff -## endfor''') - assert tmpl.render(seq=[1, 2]).strip() == '* 1\n* 2' - env = Environment('{%', '%}', '${', '}', '/*', '*/', '#', '##') - tmpl = env.from_string('''\ -/* ignore me. - I'm a multiline comment */ -# for item in seq: -* ${item} ## this is just extra stuff - ## extra stuff i just want to ignore -# endfor''') - assert tmpl.render(seq=[1, 2]).strip() == '* 1\n\n* 2' - - def test_error_messages(self, env): - def assert_error(code, expected): - try: - Template(code) - except TemplateSyntaxError as e: - assert str(e) == expected, 'unexpected error message' - else: - assert False, 'that was supposed to be an error' - - assert_error('{% for item in seq %}...{% endif %}', - "Encountered unknown tag 'endif'. Jinja was looking " - "for the following tags: 'endfor' or 'else'. The " - "innermost block that needs to be closed is 'for'.") - assert_error( - '{% if foo %}{% for item in seq %}...{% endfor %}{% endfor %}', - "Encountered unknown tag 'endfor'. Jinja was looking for " - "the following tags: 'elif' or 'else' or 'endif'. The " - "innermost block that needs to be closed is 'if'.") - assert_error('{% if foo %}', - "Unexpected end of template. Jinja was looking for the " - "following tags: 'elif' or 'else' or 'endif'. The " - "innermost block that needs to be closed is 'if'.") - assert_error('{% for item in seq %}', - "Unexpected end of template. Jinja was looking for the " - "following tags: 'endfor' or 'else'. The innermost block " - "that needs to be closed is 'for'.") - assert_error( - '{% block foo-bar-baz %}', - "Block names in Jinja have to be valid Python identifiers " - "and may not contain hyphens, use an underscore instead.") - assert_error('{% unknown_tag %}', - "Encountered unknown tag 'unknown_tag'.") - - -@pytest.mark.lexnparse -@pytest.mark.syntax -class TestSyntax(): - - def test_call(self, env): - env = Environment() - env.globals['foo'] = lambda a, b, c, e, g: a + b + c + e + g - tmpl = env.from_string( - "{{ foo('a', c='d', e='f', *['b'], **{'g': 'h'}) }}" - ) - assert tmpl.render() == 'abdfh' - - def test_slicing(self, env): - tmpl = env.from_string('{{ [1, 2, 3][:] }}|{{ [1, 2, 3][::-1] }}') - assert tmpl.render() == '[1, 2, 3]|[3, 2, 1]' - - def test_attr(self, env): - tmpl = env.from_string("{{ foo.bar }}|{{ foo['bar'] }}") - assert tmpl.render(foo={'bar': 42}) == '42|42' - - def test_subscript(self, env): - tmpl = env.from_string("{{ foo[0] }}|{{ foo[-1] }}") - assert tmpl.render(foo=[0, 1, 2]) == '0|2' - - def test_tuple(self, env): - tmpl = env.from_string('{{ () }}|{{ (1,) }}|{{ (1, 2) }}') - assert tmpl.render() == '()|(1,)|(1, 2)' - - def test_math(self, env): - tmpl = env.from_string('{{ (1 + 1 * 2) - 3 / 2 }}|{{ 2**3 }}') - assert tmpl.render() == '1.5|8' - - def test_div(self, env): - tmpl = env.from_string('{{ 3 // 2 }}|{{ 3 / 2 }}|{{ 3 % 2 }}') - assert tmpl.render() == '1|1.5|1' - - def test_unary(self, env): - tmpl = env.from_string('{{ +3 }}|{{ -3 }}') - assert tmpl.render() == '3|-3' - - def test_concat(self, env): - tmpl = env.from_string("{{ [1, 2] ~ 'foo' }}") - assert tmpl.render() == '[1, 2]foo' - - def test_compare(self, env): - tmpl = env.from_string('{{ 1 > 0 }}|{{ 1 >= 1 }}|{{ 2 < 3 }}|' - '{{ 2 == 2 }}|{{ 1 <= 1 }}') - assert tmpl.render() == 'True|True|True|True|True' - - def test_inop(self, env): - tmpl = env.from_string('{{ 1 in [1, 2, 3] }}|{{ 1 not in [1, 2, 3] }}') - assert tmpl.render() == 'True|False' - - def test_literals(self, env): - tmpl = env.from_string('{{ [] }}|{{ {} }}|{{ () }}') - assert tmpl.render().lower() == '[]|{}|()' - - def test_bool(self, env): - tmpl = env.from_string('{{ true and false }}|{{ false ' - 'or true }}|{{ not false }}') - assert tmpl.render() == 'False|True|True' - - def test_grouping(self, env): - tmpl = env.from_string( - '{{ (true and false) or (false and true) and not false }}') - assert tmpl.render() == 'False' - - def test_django_attr(self, env): - tmpl = env.from_string('{{ [1, 2, 3].0 }}|{{ [[1]].0.0 }}') - assert tmpl.render() == '1|1' - - def test_conditional_expression(self, env): - tmpl = env.from_string('''{{ 0 if true else 1 }}''') - assert tmpl.render() == '0' - - def test_short_conditional_expression(self, env): - tmpl = env.from_string('<{{ 1 if false }}>') - assert tmpl.render() == '<>' - - tmpl = env.from_string('<{{ (1 if false).bar }}>') - pytest.raises(UndefinedError, tmpl.render) - - def test_filter_priority(self, env): - tmpl = env.from_string('{{ "foo"|upper + "bar"|upper }}') - assert tmpl.render() == 'FOOBAR' - - def test_function_calls(self, env): - tests = [ - (True, '*foo, bar'), - (True, '*foo, *bar'), - (True, '*foo, bar=42'), - (True, '**foo, *bar'), - (True, '**foo, bar'), - (False, 'foo, bar'), - (False, 'foo, bar=42'), - (False, 'foo, bar=23, *args'), - (False, 'a, b=c, *d, **e'), - (False, '*foo, **bar') - ] - for should_fail, sig in tests: - if should_fail: - pytest.raises(TemplateSyntaxError, - env.from_string, '{{ foo(%s) }}' % sig) - else: - env.from_string('foo(%s)' % sig) - - def test_tuple_expr(self, env): - for tmpl in [ - '{{ () }}', - '{{ (1, 2) }}', - '{{ (1, 2,) }}', - '{{ 1, }}', - '{{ 1, 2 }}', - '{% for foo, bar in seq %}...{% endfor %}', - '{% for x in foo, bar %}...{% endfor %}', - '{% for x in foo, %}...{% endfor %}' - ]: - assert env.from_string(tmpl) - - def test_trailing_comma(self, env): - tmpl = env.from_string('{{ (1, 2,) }}|{{ [1, 2,] }}|{{ {1: 2,} }}') - assert tmpl.render().lower() == '(1, 2)|[1, 2]|{1: 2}' - - def test_block_end_name(self, env): - env.from_string('{% block foo %}...{% endblock foo %}') - pytest.raises(TemplateSyntaxError, env.from_string, - '{% block x %}{% endblock y %}') - - def test_constant_casing(self, env): - for const in True, False, None: - tmpl = env.from_string('{{ %s }}|{{ %s }}|{{ %s }}' % ( - str(const), str(const).lower(), str(const).upper() - )) - assert tmpl.render() == '%s|%s|' % (const, const) - - def test_test_chaining(self, env): - pytest.raises(TemplateSyntaxError, env.from_string, - '{{ foo is string is sequence }}') - assert env.from_string( - '{{ 42 is string or 42 is number }}' - ).render() == 'True' - - def test_string_concatenation(self, env): - tmpl = env.from_string('{{ "foo" "bar" "baz" }}') - assert tmpl.render() == 'foobarbaz' - - def test_notin(self, env): - bar = range(100) - tmpl = env.from_string('''{{ not 42 in bar }}''') - assert tmpl.render(bar=bar) == text_type(not 42 in bar) - - def test_implicit_subscribed_tuple(self, env): - class Foo(object): - def __getitem__(self, x): - return x - t = env.from_string('{{ foo[1, 2] }}') - assert t.render(foo=Foo()) == u'(1, 2)' - - def test_raw2(self, env): - tmpl = env.from_string('{% raw %}{{ FOO }} and {% BAR %}{% endraw %}') - assert tmpl.render() == '{{ FOO }} and {% BAR %}' - - def test_const(self, env): - tmpl = env.from_string( - '{{ true }}|{{ false }}|{{ none }}|' - '{{ none is defined }}|{{ missing is defined }}') - assert tmpl.render() == 'True|False|None|True|False' - - def test_neg_filter_priority(self, env): - node = env.parse('{{ -1|foo }}') - assert isinstance(node.body[0].nodes[0], nodes.Filter) - assert isinstance(node.body[0].nodes[0].node, nodes.Neg) - - def test_const_assign(self, env): - constass1 = '''{% set true = 42 %}''' - constass2 = '''{% for none in seq %}{% endfor %}''' - for tmpl in constass1, constass2: - pytest.raises(TemplateSyntaxError, env.from_string, tmpl) - - def test_localset(self, env): - tmpl = env.from_string('''{% set foo = 0 %}\ -{% for item in [1, 2] %}{% set foo = 1 %}{% endfor %}\ -{{ foo }}''') - assert tmpl.render() == '0' - - def test_parse_unary(self, env): - tmpl = env.from_string('{{ -foo["bar"] }}') - assert tmpl.render(foo={'bar': 42}) == '-42' - tmpl = env.from_string('{{ -foo["bar"]|abs }}') - assert tmpl.render(foo={'bar': 42}) == '42' - - -@pytest.mark.lexnparse -@pytest.mark.lstripblocks -class TestLstripBlocks(): - - def test_lstrip(self, env): - env = Environment(lstrip_blocks=True, trim_blocks=False) - tmpl = env.from_string(''' {% if True %}\n {% endif %}''') - assert tmpl.render() == "\n" - - def test_lstrip_trim(self, env): - env = Environment(lstrip_blocks=True, trim_blocks=True) - tmpl = env.from_string(''' {% if True %}\n {% endif %}''') - assert tmpl.render() == "" - - def test_no_lstrip(self, env): - env = Environment(lstrip_blocks=True, trim_blocks=False) - tmpl = env.from_string(''' {%+ if True %}\n {%+ endif %}''') - assert tmpl.render() == " \n " - - def test_lstrip_endline(self, env): - env = Environment(lstrip_blocks=True, trim_blocks=False) - tmpl = env.from_string( - ''' hello{% if True %}\n goodbye{% endif %}''') - assert tmpl.render() == " hello\n goodbye" - - def test_lstrip_inline(self, env): - env = Environment(lstrip_blocks=True, trim_blocks=False) - tmpl = env.from_string(''' {% if True %}hello {% endif %}''') - assert tmpl.render() == 'hello ' - - def test_lstrip_nested(self, env): - env = Environment(lstrip_blocks=True, trim_blocks=False) - tmpl = env.from_string( - ''' {% if True %}a {% if True %}b {% endif %}c {% endif %}''') - assert tmpl.render() == 'a b c ' - - def test_lstrip_left_chars(self, env): - env = Environment(lstrip_blocks=True, trim_blocks=False) - tmpl = env.from_string(''' abc {% if True %} - hello{% endif %}''') - assert tmpl.render() == ' abc \n hello' - - def test_lstrip_embeded_strings(self, env): - env = Environment(lstrip_blocks=True, trim_blocks=False) - tmpl = env.from_string(''' {% set x = " {% str %} " %}{{ x }}''') - assert tmpl.render() == ' {% str %} ' - - def test_lstrip_preserve_leading_newlines(self, env): - env = Environment(lstrip_blocks=True, trim_blocks=False) - tmpl = env.from_string('''\n\n\n{% set hello = 1 %}''') - assert tmpl.render() == '\n\n\n' - - def test_lstrip_comment(self, env): - env = Environment(lstrip_blocks=True, trim_blocks=False) - tmpl = env.from_string(''' {# if True #} -hello - {#endif#}''') - assert tmpl.render() == '\nhello\n' - - def test_lstrip_angle_bracket_simple(self, env): - env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##', - lstrip_blocks=True, trim_blocks=True) - tmpl = env.from_string(''' <% if True %>hello <% endif %>''') - assert tmpl.render() == 'hello ' - - def test_lstrip_angle_bracket_comment(self, env): - env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##', - lstrip_blocks=True, trim_blocks=True) - tmpl = env.from_string(''' <%# if True %>hello <%# endif %>''') - assert tmpl.render() == 'hello ' - - def test_lstrip_angle_bracket(self, env): - env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##', - lstrip_blocks=True, trim_blocks=True) - tmpl = env.from_string('''\ - <%# regular comment %> - <% for item in seq %> -${item} ## the rest of the stuff - <% endfor %>''') - assert tmpl.render(seq=range(5)) == \ - ''.join('%s\n' % x for x in range(5)) - - def test_lstrip_angle_bracket_compact(self, env): - env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##', - lstrip_blocks=True, trim_blocks=True) - tmpl = env.from_string('''\ - <%#regular comment%> - <%for item in seq%> -${item} ## the rest of the stuff - <%endfor%>''') - assert tmpl.render(seq=range(5)) == \ - ''.join('%s\n' % x for x in range(5)) - - def test_php_syntax_with_manual(self, env): - env = Environment('', '', '', - lstrip_blocks=True, trim_blocks=True) - tmpl = env.from_string('''\ - - - - ''') - assert tmpl.render(seq=range(5)) == '01234' - - def test_php_syntax(self, env): - env = Environment('', '', '', - lstrip_blocks=True, trim_blocks=True) - tmpl = env.from_string('''\ - - - - ''') - assert tmpl.render(seq=range(5)) \ - == ''.join(' %s\n' % x for x in range(5)) - - def test_php_syntax_compact(self, env): - env = Environment('', '', '', - lstrip_blocks=True, trim_blocks=True) - tmpl = env.from_string('''\ - - - - ''') - assert tmpl.render(seq=range(5)) \ - == ''.join(' %s\n' % x for x in range(5)) - - def test_erb_syntax(self, env): - env = Environment('<%', '%>', '<%=', '%>', '<%#', '%>', - lstrip_blocks=True, trim_blocks=True) - # env.from_string('') - # for n,r in env.lexer.rules.iteritems(): - # print n - # print env.lexer.rules['root'][0][0].pattern - # print "'%s'" % tmpl.render(seq=range(5)) - tmpl = env.from_string('''\ -<%# I'm a comment, I'm not interesting %> - <% for item in seq %> - <%= item %> - <% endfor %> -''') - assert tmpl.render(seq=range(5)) \ - == ''.join(' %s\n' % x for x in range(5)) - - def test_erb_syntax_with_manual(self, env): - env = Environment('<%', '%>', '<%=', '%>', '<%#', '%>', - lstrip_blocks=True, trim_blocks=True) - tmpl = env.from_string('''\ -<%# I'm a comment, I'm not interesting %> - <% for item in seq -%> - <%= item %> - <%- endfor %>''') - assert tmpl.render(seq=range(5)) == '01234' - - def test_erb_syntax_no_lstrip(self, env): - env = Environment('<%', '%>', '<%=', '%>', '<%#', '%>', - lstrip_blocks=True, trim_blocks=True) - tmpl = env.from_string('''\ -<%# I'm a comment, I'm not interesting %> - <%+ for item in seq -%> - <%= item %> - <%- endfor %>''') - assert tmpl.render(seq=range(5)) == ' 01234' - - def test_comment_syntax(self, env): - env = Environment('', '${', '}', '', - lstrip_blocks=True, trim_blocks=True) - tmpl = env.from_string('''\ -\ - - ${item} -''') - assert tmpl.render(seq=range(5)) == '01234' diff --git a/deps/v8_inspector/third_party/jinja2/tests/test_loader.py b/deps/v8_inspector/third_party/jinja2/tests/test_loader.py deleted file mode 100644 index 6d22fad390cb80..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/test_loader.py +++ /dev/null @@ -1,220 +0,0 @@ -# -*- coding: utf-8 -*- -""" - jinja2.testsuite.loader - ~~~~~~~~~~~~~~~~~~~~~~~ - - Test the loaders. - - :copyright: (c) 2010 by the Jinja Team. - :license: BSD, see LICENSE for more details. -""" -import os -import sys -import tempfile -import shutil -import pytest - -from jinja2 import Environment, loaders -from jinja2._compat import PYPY, PY2 -from jinja2.loaders import split_template_path -from jinja2.exceptions import TemplateNotFound - - -@pytest.mark.loaders -class TestLoaders(): - - def test_dict_loader(self, dict_loader): - env = Environment(loader=dict_loader) - tmpl = env.get_template('justdict.html') - assert tmpl.render().strip() == 'FOO' - pytest.raises(TemplateNotFound, env.get_template, 'missing.html') - - def test_package_loader(self, package_loader): - env = Environment(loader=package_loader) - tmpl = env.get_template('test.html') - assert tmpl.render().strip() == 'BAR' - pytest.raises(TemplateNotFound, env.get_template, 'missing.html') - - def test_filesystem_loader(self, filesystem_loader): - env = Environment(loader=filesystem_loader) - tmpl = env.get_template('test.html') - assert tmpl.render().strip() == 'BAR' - tmpl = env.get_template('foo/test.html') - assert tmpl.render().strip() == 'FOO' - pytest.raises(TemplateNotFound, env.get_template, 'missing.html') - - def test_choice_loader(self, choice_loader): - env = Environment(loader=choice_loader) - tmpl = env.get_template('justdict.html') - assert tmpl.render().strip() == 'FOO' - tmpl = env.get_template('test.html') - assert tmpl.render().strip() == 'BAR' - pytest.raises(TemplateNotFound, env.get_template, 'missing.html') - - def test_function_loader(self, function_loader): - env = Environment(loader=function_loader) - tmpl = env.get_template('justfunction.html') - assert tmpl.render().strip() == 'FOO' - pytest.raises(TemplateNotFound, env.get_template, 'missing.html') - - def test_prefix_loader(self, prefix_loader): - env = Environment(loader=prefix_loader) - tmpl = env.get_template('a/test.html') - assert tmpl.render().strip() == 'BAR' - tmpl = env.get_template('b/justdict.html') - assert tmpl.render().strip() == 'FOO' - pytest.raises(TemplateNotFound, env.get_template, 'missing') - - def test_caching(self): - changed = False - - class TestLoader(loaders.BaseLoader): - def get_source(self, environment, template): - return u'foo', None, lambda: not changed - env = Environment(loader=TestLoader(), cache_size=-1) - tmpl = env.get_template('template') - assert tmpl is env.get_template('template') - changed = True - assert tmpl is not env.get_template('template') - changed = False - - env = Environment(loader=TestLoader(), cache_size=0) - assert env.get_template('template') \ - is not env.get_template('template') - - env = Environment(loader=TestLoader(), cache_size=2) - t1 = env.get_template('one') - t2 = env.get_template('two') - assert t2 is env.get_template('two') - assert t1 is env.get_template('one') - t3 = env.get_template('three') - assert 'one' in env.cache - assert 'two' not in env.cache - assert 'three' in env.cache - - def test_dict_loader_cache_invalidates(self): - mapping = {'foo': "one"} - env = Environment(loader=loaders.DictLoader(mapping)) - assert env.get_template('foo').render() == "one" - mapping['foo'] = "two" - assert env.get_template('foo').render() == "two" - - def test_split_template_path(self): - assert split_template_path('foo/bar') == ['foo', 'bar'] - assert split_template_path('./foo/bar') == ['foo', 'bar'] - pytest.raises(TemplateNotFound, split_template_path, '../foo') - - -@pytest.mark.loaders -@pytest.mark.moduleloader -class TestModuleLoader(): - archive = None - - def compile_down(self, prefix_loader, zip='deflated', py_compile=False): - log = [] - self.reg_env = Environment(loader=prefix_loader) - if zip is not None: - fd, self.archive = tempfile.mkstemp(suffix='.zip') - os.close(fd) - else: - self.archive = tempfile.mkdtemp() - self.reg_env.compile_templates(self.archive, zip=zip, - log_function=log.append, - py_compile=py_compile) - self.mod_env = Environment(loader=loaders.ModuleLoader(self.archive)) - return ''.join(log) - - def teardown(self): - if hasattr(self, 'mod_env'): - if os.path.isfile(self.archive): - os.remove(self.archive) - else: - shutil.rmtree(self.archive) - self.archive = None - - def test_log(self, prefix_loader): - log = self.compile_down(prefix_loader) - assert 'Compiled "a/foo/test.html" as ' \ - 'tmpl_a790caf9d669e39ea4d280d597ec891c4ef0404a' in log - assert 'Finished compiling templates' in log - assert 'Could not compile "a/syntaxerror.html": ' \ - 'Encountered unknown tag \'endif\'' in log - - def _test_common(self): - tmpl1 = self.reg_env.get_template('a/test.html') - tmpl2 = self.mod_env.get_template('a/test.html') - assert tmpl1.render() == tmpl2.render() - - tmpl1 = self.reg_env.get_template('b/justdict.html') - tmpl2 = self.mod_env.get_template('b/justdict.html') - assert tmpl1.render() == tmpl2.render() - - def test_deflated_zip_compile(self, prefix_loader): - self.compile_down(prefix_loader, zip='deflated') - self._test_common() - - def test_stored_zip_compile(self, prefix_loader): - self.compile_down(prefix_loader, zip='stored') - self._test_common() - - def test_filesystem_compile(self, prefix_loader): - self.compile_down(prefix_loader, zip=None) - self._test_common() - - def test_weak_references(self, prefix_loader): - self.compile_down(prefix_loader) - tmpl = self.mod_env.get_template('a/test.html') - key = loaders.ModuleLoader.get_template_key('a/test.html') - name = self.mod_env.loader.module.__name__ - - assert hasattr(self.mod_env.loader.module, key) - assert name in sys.modules - - # unset all, ensure the module is gone from sys.modules - self.mod_env = tmpl = None - - try: - import gc - gc.collect() - except: - pass - - assert name not in sys.modules - - # This test only makes sense on non-pypy python 2 - @pytest.mark.skipif( - not (PY2 and not PYPY), - reason='This test only makes sense on non-pypy python 2') - def test_byte_compilation(self, prefix_loader): - log = self.compile_down(prefix_loader, py_compile=True) - assert 'Byte-compiled "a/test.html"' in log - tmpl1 = self.mod_env.get_template('a/test.html') - mod = self.mod_env.loader.module. \ - tmpl_3c4ddf650c1a73df961a6d3d2ce2752f1b8fd490 - assert mod.__file__.endswith('.pyc') - - def test_choice_loader(self, prefix_loader): - log = self.compile_down(prefix_loader) - - self.mod_env.loader = loaders.ChoiceLoader([ - self.mod_env.loader, - loaders.DictLoader({'DICT_SOURCE': 'DICT_TEMPLATE'}) - ]) - - tmpl1 = self.mod_env.get_template('a/test.html') - assert tmpl1.render() == 'BAR' - tmpl2 = self.mod_env.get_template('DICT_SOURCE') - assert tmpl2.render() == 'DICT_TEMPLATE' - - def test_prefix_loader(self, prefix_loader): - log = self.compile_down(prefix_loader) - - self.mod_env.loader = loaders.PrefixLoader({ - 'MOD': self.mod_env.loader, - 'DICT': loaders.DictLoader({'test.html': 'DICT_TEMPLATE'}) - }) - - tmpl1 = self.mod_env.get_template('MOD/a/test.html') - assert tmpl1.render() == 'BAR' - tmpl2 = self.mod_env.get_template('DICT/test.html') - assert tmpl2.render() == 'DICT_TEMPLATE' diff --git a/deps/v8_inspector/third_party/jinja2/tests/test_regression.py b/deps/v8_inspector/third_party/jinja2/tests/test_regression.py deleted file mode 100644 index a4aa157110395f..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/test_regression.py +++ /dev/null @@ -1,278 +0,0 @@ -# -*- coding: utf-8 -*- -""" - jinja2.testsuite.regression - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - Tests corner cases and bugs. - - :copyright: (c) 2010 by the Jinja Team. - :license: BSD, see LICENSE for more details. -""" -import pytest - -from jinja2 import Template, Environment, DictLoader, TemplateSyntaxError, \ - TemplateNotFound, PrefixLoader -from jinja2._compat import text_type - - -@pytest.mark.regression -class TestCorner(): - - def test_assigned_scoping(self, env): - t = env.from_string(''' - {%- for item in (1, 2, 3, 4) -%} - [{{ item }}] - {%- endfor %} - {{- item -}} - ''') - assert t.render(item=42) == '[1][2][3][4]42' - - t = env.from_string(''' - {%- for item in (1, 2, 3, 4) -%} - [{{ item }}] - {%- endfor %} - {%- set item = 42 %} - {{- item -}} - ''') - assert t.render() == '[1][2][3][4]42' - - t = env.from_string(''' - {%- set item = 42 %} - {%- for item in (1, 2, 3, 4) -%} - [{{ item }}] - {%- endfor %} - {{- item -}} - ''') - assert t.render() == '[1][2][3][4]42' - - def test_closure_scoping(self, env): - t = env.from_string(''' - {%- set wrapper = "" %} - {%- for item in (1, 2, 3, 4) %} - {%- macro wrapper() %}[{{ item }}]{% endmacro %} - {{- wrapper() }} - {%- endfor %} - {{- wrapper -}} - ''') - assert t.render() == '[1][2][3][4]' - - t = env.from_string(''' - {%- for item in (1, 2, 3, 4) %} - {%- macro wrapper() %}[{{ item }}]{% endmacro %} - {{- wrapper() }} - {%- endfor %} - {%- set wrapper = "" %} - {{- wrapper -}} - ''') - assert t.render() == '[1][2][3][4]' - - t = env.from_string(''' - {%- for item in (1, 2, 3, 4) %} - {%- macro wrapper() %}[{{ item }}]{% endmacro %} - {{- wrapper() }} - {%- endfor %} - {{- wrapper -}} - ''') - assert t.render(wrapper=23) == '[1][2][3][4]23' - - -@pytest.mark.regression -class TestBug(): - - def test_keyword_folding(self, env): - env = Environment() - env.filters['testing'] = lambda value, some: value + some - assert env.from_string("{{ 'test'|testing(some='stuff') }}") \ - .render() == 'teststuff' - - def test_extends_output_bugs(self, env): - env = Environment(loader=DictLoader({ - 'parent.html': '(({% block title %}{% endblock %}))' - })) - - t = env.from_string( - '{% if expr %}{% extends "parent.html" %}{% endif %}' - '[[{% block title %}title{% endblock %}]]' - '{% for item in [1, 2, 3] %}({{ item }}){% endfor %}' - ) - assert t.render(expr=False) == '[[title]](1)(2)(3)' - assert t.render(expr=True) == '((title))' - - def test_urlize_filter_escaping(self, env): - tmpl = env.from_string('{{ "http://www.example.org/'\ - 'http://www.example.org/<foo' - - def test_loop_call_loop(self, env): - tmpl = env.from_string(''' - - {% macro test() %} - {{ caller() }} - {% endmacro %} - - {% for num1 in range(5) %} - {% call test() %} - {% for num2 in range(10) %} - {{ loop.index }} - {% endfor %} - {% endcall %} - {% endfor %} - - ''') - - assert tmpl.render().split() \ - == [text_type(x) for x in range(1, 11)] * 5 - - def test_weird_inline_comment(self, env): - env = Environment(line_statement_prefix='%') - pytest.raises(TemplateSyntaxError, env.from_string, - '% for item in seq {# missing #}\n...% endfor') - - def test_old_macro_loop_scoping_bug(self, env): - tmpl = env.from_string('{% for i in (1, 2) %}{{ i }}{% endfor %}' - '{% macro i() %}3{% endmacro %}{{ i() }}') - assert tmpl.render() == '123' - - def test_partial_conditional_assignments(self, env): - tmpl = env.from_string('{% if b %}{% set a = 42 %}{% endif %}{{ a }}') - assert tmpl.render(a=23) == '23' - assert tmpl.render(b=True) == '42' - - def test_stacked_locals_scoping_bug(self, env): - env = Environment(line_statement_prefix='#') - t = env.from_string('''\ -# for j in [1, 2]: -# set x = 1 -# for i in [1, 2]: -# print x -# if i % 2 == 0: -# set x = x + 1 -# endif -# endfor -# endfor -# if a -# print 'A' -# elif b -# print 'B' -# elif c == d -# print 'C' -# else -# print 'D' -# endif - ''') - assert t.render(a=0, b=False, c=42, d=42.0) == '1111C' - - def test_stacked_locals_scoping_bug_twoframe(self, env): - t = Template(''' - {% set x = 1 %} - {% for item in foo %} - {% if item == 1 %} - {% set x = 2 %} - {% endif %} - {% endfor %} - {{ x }} - ''') - rv = t.render(foo=[1]).strip() - assert rv == u'1' - - def test_call_with_args(self, env): - t = Template("""{% macro dump_users(users) -%} -
    - {%- for user in users -%} -
  • {{ user.username|e }}

    {{ caller(user) }}
  • - {%- endfor -%} -
- {%- endmacro -%} - - {% call(user) dump_users(list_of_user) -%} -
-
Realname
-
{{ user.realname|e }}
-
Description
-
{{ user.description }}
-
- {% endcall %}""") - - assert [x.strip() for x in t.render(list_of_user=[{ - 'username': 'apo', - 'realname': 'something else', - 'description': 'test' - }]).splitlines()] == [ - u'
  • apo

    ', - u'
    Realname
    ', - u'
    something else
    ', - u'
    Description
    ', - u'
    test
    ', - u'
    ', - u'
' - ] - - def test_empty_if_condition_fails(self, env): - pytest.raises(TemplateSyntaxError, - Template, '{% if %}....{% endif %}') - pytest.raises(TemplateSyntaxError, - Template, '{% if foo %}...{% elif %}...{% endif %}') - pytest.raises(TemplateSyntaxError, - Template, '{% for x in %}..{% endfor %}') - - def test_recursive_loop_bug(self, env): - tpl1 = Template(""" - {% for p in foo recursive%} - {{p.bar}} - {% for f in p.fields recursive%} - {{f.baz}} - {{p.bar}} - {% if f.rec %} - {{ loop(f.sub) }} - {% endif %} - {% endfor %} - {% endfor %} - """) - - tpl2 = Template(""" - {% for p in foo%} - {{p.bar}} - {% for f in p.fields recursive%} - {{f.baz}} - {{p.bar}} - {% if f.rec %} - {{ loop(f.sub) }} - {% endif %} - {% endfor %} - {% endfor %} - """) - - def test_else_loop_bug(self, env): - t = Template(''' - {% for x in y %} - {{ loop.index0 }} - {% else %} - {% for i in range(3) %}{{ i }}{% endfor %} - {% endfor %} - ''') - assert t.render(y=[]).strip() == '012' - - def test_correct_prefix_loader_name(self, env): - env = Environment(loader=PrefixLoader({ - 'foo': DictLoader({}) - })) - try: - env.get_template('foo/bar.html') - except TemplateNotFound as e: - assert e.name == 'foo/bar.html' - else: - assert False, 'expected error here' - - def test_contextfunction_callable_classes(self, env): - from jinja2.utils import contextfunction - - class CallableClass(object): - @contextfunction - def __call__(self, ctx): - return ctx.resolve('hello') - - tpl = Template("""{{ callableclass() }}""") - output = tpl.render(callableclass=CallableClass(), hello='TEST') - expected = 'TEST' - - assert output == expected diff --git a/deps/v8_inspector/third_party/jinja2/tests/test_security.py b/deps/v8_inspector/third_party/jinja2/tests/test_security.py deleted file mode 100644 index e5b463fc989263..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/test_security.py +++ /dev/null @@ -1,161 +0,0 @@ -# -*- coding: utf-8 -*- -""" - jinja2.testsuite.security - ~~~~~~~~~~~~~~~~~~~~~~~~~ - - Checks the sandbox and other security features. - - :copyright: (c) 2010 by the Jinja Team. - :license: BSD, see LICENSE for more details. -""" -import pytest - -from jinja2 import Environment -from jinja2.sandbox import SandboxedEnvironment, \ - ImmutableSandboxedEnvironment, unsafe -from jinja2 import Markup, escape -from jinja2.exceptions import SecurityError, TemplateSyntaxError, \ - TemplateRuntimeError -from jinja2._compat import text_type - - -class PrivateStuff(object): - - def bar(self): - return 23 - - @unsafe - def foo(self): - return 42 - - def __repr__(self): - return 'PrivateStuff' - - -class PublicStuff(object): - bar = lambda self: 23 - _foo = lambda self: 42 - - def __repr__(self): - return 'PublicStuff' - - -@pytest.mark.sandbox -class TestSandbox(): - - def test_unsafe(self, env): - env = SandboxedEnvironment() - pytest.raises(SecurityError, env.from_string("{{ foo.foo() }}").render, - foo=PrivateStuff()) - assert env.from_string("{{ foo.bar() }}").render(foo=PrivateStuff()) == '23' - - pytest.raises(SecurityError, - env.from_string("{{ foo._foo() }}").render, - foo=PublicStuff()) - assert env.from_string("{{ foo.bar() }}").render(foo=PublicStuff()) == '23' - assert env.from_string("{{ foo.__class__ }}").render(foo=42) == '' - assert env.from_string("{{ foo.func_code }}").render(foo=lambda:None) == '' - # security error comes from __class__ already. - pytest.raises(SecurityError, env.from_string( - "{{ foo.__class__.__subclasses__() }}").render, foo=42) - - def test_immutable_environment(self, env): - env = ImmutableSandboxedEnvironment() - pytest.raises(SecurityError, env.from_string( - '{{ [].append(23) }}').render) - pytest.raises(SecurityError, env.from_string( - '{{ {1:2}.clear() }}').render) - - def test_restricted(self, env): - env = SandboxedEnvironment() - pytest.raises(TemplateSyntaxError, env.from_string, - "{% for item.attribute in seq %}...{% endfor %}") - pytest.raises(TemplateSyntaxError, env.from_string, - "{% for foo, bar.baz in seq %}...{% endfor %}") - - def test_markup_operations(self, env): - # adding two strings should escape the unsafe one - unsafe = '' - safe = Markup('username') - assert unsafe + safe == text_type(escape(unsafe)) + text_type(safe) - - # string interpolations are safe to use too - assert Markup('%s') % '' == \ - '<bad user>' - assert Markup('%(username)s') % { - 'username': '' - } == '<bad user>' - - # an escaped object is markup too - assert type(Markup('foo') + 'bar') is Markup - - # and it implements __html__ by returning itself - x = Markup("foo") - assert x.__html__() is x - - # it also knows how to treat __html__ objects - class Foo(object): - def __html__(self): - return 'awesome' - - def __unicode__(self): - return 'awesome' - assert Markup(Foo()) == 'awesome' - assert Markup('%s') % Foo() == \ - 'awesome' - - # escaping and unescaping - assert escape('"<>&\'') == '"<>&'' - assert Markup("Foo & Bar").striptags() == "Foo & Bar" - assert Markup("<test>").unescape() == "" - - def test_template_data(self, env): - env = Environment(autoescape=True) - t = env.from_string('{% macro say_hello(name) %}' - '

Hello {{ name }}!

{% endmacro %}' - '{{ say_hello("foo") }}') - escaped_out = '

Hello <blink>foo</blink>!

' - assert t.render() == escaped_out - assert text_type(t.module) == escaped_out - assert escape(t.module) == escaped_out - assert t.module.say_hello('foo') == escaped_out - assert escape(t.module.say_hello('foo')) == escaped_out - - def test_attr_filter(self, env): - env = SandboxedEnvironment() - tmpl = env.from_string('{{ cls|attr("__subclasses__")() }}') - pytest.raises(SecurityError, tmpl.render, cls=int) - - def test_binary_operator_intercepting(self, env): - def disable_op(left, right): - raise TemplateRuntimeError('that operator so does not work') - for expr, ctx, rv in ('1 + 2', {}, '3'), ('a + 2', {'a': 2}, '4'): - env = SandboxedEnvironment() - env.binop_table['+'] = disable_op - t = env.from_string('{{ %s }}' % expr) - assert t.render(ctx) == rv - env.intercepted_binops = frozenset(['+']) - t = env.from_string('{{ %s }}' % expr) - try: - t.render(ctx) - except TemplateRuntimeError as e: - pass - else: - assert False, 'expected runtime error' - - def test_unary_operator_intercepting(self, env): - def disable_op(arg): - raise TemplateRuntimeError('that operator so does not work') - for expr, ctx, rv in ('-1', {}, '-1'), ('-a', {'a': 2}, '-2'): - env = SandboxedEnvironment() - env.unop_table['-'] = disable_op - t = env.from_string('{{ %s }}' % expr) - assert t.render(ctx) == rv - env.intercepted_unops = frozenset(['-']) - t = env.from_string('{{ %s }}' % expr) - try: - t.render(ctx) - except TemplateRuntimeError as e: - pass - else: - assert False, 'expected runtime error' diff --git a/deps/v8_inspector/third_party/jinja2/tests/test_tests.py b/deps/v8_inspector/third_party/jinja2/tests/test_tests.py deleted file mode 100644 index 9e54038c9a2dc1..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/test_tests.py +++ /dev/null @@ -1,104 +0,0 @@ -# -*- coding: utf-8 -*- -""" - jinja2.testsuite.tests - ~~~~~~~~~~~~~~~~~~~~~~ - - Who tests the tests? - - :copyright: (c) 2010 by the Jinja Team. - :license: BSD, see LICENSE for more details. -""" -import pytest - -from jinja2 import Markup, Environment - - -@pytest.mark.test_tests -class TestTestsCase(): - - def test_defined(self, env): - tmpl = env.from_string('{{ missing is defined }}|' - '{{ true is defined }}') - assert tmpl.render() == 'False|True' - - def test_even(self, env): - tmpl = env.from_string('''{{ 1 is even }}|{{ 2 is even }}''') - assert tmpl.render() == 'False|True' - - def test_odd(self, env): - tmpl = env.from_string('''{{ 1 is odd }}|{{ 2 is odd }}''') - assert tmpl.render() == 'True|False' - - def test_lower(self, env): - tmpl = env.from_string('''{{ "foo" is lower }}|{{ "FOO" is lower }}''') - assert tmpl.render() == 'True|False' - - def test_typechecks(self, env): - tmpl = env.from_string(''' - {{ 42 is undefined }} - {{ 42 is defined }} - {{ 42 is none }} - {{ none is none }} - {{ 42 is number }} - {{ 42 is string }} - {{ "foo" is string }} - {{ "foo" is sequence }} - {{ [1] is sequence }} - {{ range is callable }} - {{ 42 is callable }} - {{ range(5) is iterable }} - {{ {} is mapping }} - {{ mydict is mapping }} - {{ [] is mapping }} - {{ 10 is number }} - {{ (10 ** 100) is number }} - {{ 3.14159 is number }} - {{ complex is number }} - ''') - - class MyDict(dict): - pass - - assert tmpl.render(mydict=MyDict(), complex=complex(1, 2)).split() == [ - 'False', 'True', 'False', 'True', 'True', 'False', - 'True', 'True', 'True', 'True', 'False', 'True', - 'True', 'True', 'False', 'True', 'True', 'True', 'True' - ] - - def test_sequence(self, env): - tmpl = env.from_string( - '{{ [1, 2, 3] is sequence }}|' - '{{ "foo" is sequence }}|' - '{{ 42 is sequence }}' - ) - assert tmpl.render() == 'True|True|False' - - def test_upper(self, env): - tmpl = env.from_string('{{ "FOO" is upper }}|{{ "foo" is upper }}') - assert tmpl.render() == 'True|False' - - def test_equalto(self, env): - tmpl = env.from_string('{{ foo is equalto 12 }}|' - '{{ foo is equalto 0 }}|' - '{{ foo is equalto (3 * 4) }}|' - '{{ bar is equalto "baz" }}|' - '{{ bar is equalto "zab" }}|' - '{{ bar is equalto ("ba" + "z") }}|' - '{{ bar is equalto bar }}|' - '{{ bar is equalto foo }}') - assert tmpl.render(foo=12, bar="baz") \ - == 'True|False|True|True|False|True|True|False' - - def test_sameas(self, env): - tmpl = env.from_string('{{ foo is sameas false }}|' - '{{ 0 is sameas false }}') - assert tmpl.render(foo=False) == 'True|False' - - def test_no_paren_for_arg1(self, env): - tmpl = env.from_string('{{ foo is sameas none }}') - assert tmpl.render(foo=None) == 'True' - - def test_escaped(self, env): - env = Environment(autoescape=True) - tmpl = env.from_string('{{ x is escaped }}|{{ y is escaped }}') - assert tmpl.render(x='foo', y=Markup('foo')) == 'False|True' diff --git a/deps/v8_inspector/third_party/jinja2/tests/test_utils.py b/deps/v8_inspector/third_party/jinja2/tests/test_utils.py deleted file mode 100644 index 373103618d2f30..00000000000000 --- a/deps/v8_inspector/third_party/jinja2/tests/test_utils.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- -""" - jinja2.testsuite.utils - ~~~~~~~~~~~~~~~~~~~~~~ - - Tests utilities jinja uses. - - :copyright: (c) 2010 by the Jinja Team. - :license: BSD, see LICENSE for more details. -""" -import gc - -import pytest - -import pickle - -from jinja2.utils import LRUCache, escape, object_type_repr - - -@pytest.mark.utils -@pytest.mark.lrucache -class TestLRUCache(): - - def test_simple(self): - d = LRUCache(3) - d["a"] = 1 - d["b"] = 2 - d["c"] = 3 - d["a"] - d["d"] = 4 - assert len(d) == 3 - assert 'a' in d and 'c' in d and 'd' in d and 'b' not in d - - def test_pickleable(self): - cache = LRUCache(2) - cache["foo"] = 42 - cache["bar"] = 23 - cache["foo"] - - for protocol in range(3): - copy = pickle.loads(pickle.dumps(cache, protocol)) - assert copy.capacity == cache.capacity - assert copy._mapping == cache._mapping - assert copy._queue == cache._queue - - -@pytest.mark.utils -@pytest.mark.helpers -class TestHelpers(): - - def test_object_type_repr(self): - class X(object): - pass - assert object_type_repr(42) == 'int object' - assert object_type_repr([]) == 'list object' - assert object_type_repr(X()) == 'test_utils.X object' - assert object_type_repr(None) == 'None' - assert object_type_repr(Ellipsis) == 'Ellipsis' - - -@pytest.mark.utils -@pytest.mark.markupleak -@pytest.mark.skipif(hasattr(escape, 'func_code'), - reason='this test only tests the c extension') -class TestMarkupLeak(): - - def test_markup_leaks(self): - counts = set() - for count in range(20): - for item in range(1000): - escape("foo") - escape("") - escape(u"foo") - escape(u"") - counts.add(len(gc.get_objects())) - assert len(counts) == 1, 'ouch, c extension seems to leak objects'