yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 1 | /* |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 2 | * Copyright (C) 2013 Apple Inc. All rights reserved. |
pfeldman@chromium.org | 52ba9e6 | 2012-06-19 23:21:03 +0000 | [diff] [blame] | 3 | * Copyright (C) 2012 Google Inc. All rights reserved. |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are |
| 7 | * met: |
| 8 | * |
| 9 | * * Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * * Redistributions in binary form must reproduce the above |
| 12 | * copyright notice, this list of conditions and the following disclaimer |
| 13 | * in the documentation and/or other materials provided with the |
| 14 | * distribution. |
| 15 | * * Neither the name of Google Inc. nor the names of its |
| 16 | * contributors may be used to endorse or promote products derived from |
| 17 | * this software without specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | */ |
| 31 | |
| 32 | #include "config.h" |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 33 | #include "InjectedScript.h" |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 34 | |
ross.kirsling@sony.com | e257a3b | 2020-05-19 23:56:00 +0000 | [diff] [blame] | 35 | #include "JSCInlines.h" |
drousso@apple.com | 3a3286d | 2019-01-15 08:25:33 +0000 | [diff] [blame] | 36 | #include "JSLock.h" |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 37 | #include "ScriptFunctionCall.h" |
| 38 | #include "ScriptObject.h" |
bburg@apple.com | 61f04d6 | 2017-11-28 19:58:16 +0000 | [diff] [blame] | 39 | #include <wtf/JSONValues.h> |
drousso@apple.com | 3a3286d | 2019-01-15 08:25:33 +0000 | [diff] [blame] | 40 | #include <wtf/Vector.h> |
weinig@apple.com | 3f5ab02 | 2012-09-06 17:36:48 +0000 | [diff] [blame] | 41 | #include <wtf/text/WTFString.h> |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 42 | |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 43 | namespace Inspector { |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 44 | |
yurys@chromium.org | 7256c3a | 2011-04-04 08:08:28 +0000 | [diff] [blame] | 45 | InjectedScript::InjectedScript() |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 46 | : InjectedScriptBase("InjectedScript"_s) |
yurys@chromium.org | 7256c3a | 2011-04-04 08:08:28 +0000 | [diff] [blame] | 47 | { |
| 48 | } |
| 49 | |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 50 | InjectedScript::InjectedScript(Deprecated::ScriptObject injectedScriptObject, InspectorEnvironment* environment) |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 51 | : InjectedScriptBase("InjectedScript"_s, injectedScriptObject, environment) |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 52 | { |
| 53 | } |
| 54 | |
| 55 | InjectedScript::~InjectedScript() |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 56 | { |
| 57 | } |
| 58 | |
darin@apple.com | a4ddc78 | 2021-05-30 16:11:40 +0000 | [diff] [blame] | 59 | void InjectedScript::execute(Protocol::ErrorString& errorString, const String& functionString, ExecuteOptions&& options, RefPtr<Protocol::Runtime::RemoteObject>& result, std::optional<bool>& wasThrown, std::optional<int>& savedResultIndex) |
drousso@apple.com | 3a3286d | 2019-01-15 08:25:33 +0000 | [diff] [blame] | 60 | { |
| 61 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "execute"_s, inspectorEnvironment()->functionCallHandler()); |
| 62 | function.appendArgument(functionString); |
| 63 | function.appendArgument(options.objectGroup); |
| 64 | function.appendArgument(options.includeCommandLineAPI); |
| 65 | function.appendArgument(options.returnByValue); |
| 66 | function.appendArgument(options.generatePreview); |
| 67 | function.appendArgument(options.saveResult); |
| 68 | function.appendArgument(arrayFromVector(WTFMove(options.args))); |
| 69 | makeEvalCall(errorString, function, result, wasThrown, savedResultIndex); |
| 70 | } |
| 71 | |
darin@apple.com | a4ddc78 | 2021-05-30 16:11:40 +0000 | [diff] [blame] | 72 | void InjectedScript::evaluate(Protocol::ErrorString& errorString, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Protocol::Runtime::RemoteObject>& result, std::optional<bool>& wasThrown, std::optional<int>& savedResultIndex) |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 73 | { |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 74 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "evaluate"_s, inspectorEnvironment()->functionCallHandler()); |
pfeldman@chromium.org | 654a83d | 2011-01-19 09:00:58 +0000 | [diff] [blame] | 75 | function.appendArgument(expression); |
| 76 | function.appendArgument(objectGroup); |
pfeldman@chromium.org | 9c856a3 | 2011-01-26 10:19:04 +0000 | [diff] [blame] | 77 | function.appendArgument(includeCommandLineAPI); |
pfeldman@chromium.org | f40526f | 2011-08-04 16:09:00 +0000 | [diff] [blame] | 78 | function.appendArgument(returnByValue); |
yurys@chromium.org | c3ce094 | 2012-11-01 12:17:00 +0000 | [diff] [blame] | 79 | function.appendArgument(generatePreview); |
joepeck@webkit.org | 029930dd | 2015-02-27 01:15:23 +0000 | [diff] [blame] | 80 | function.appendArgument(saveResult); |
| 81 | makeEvalCall(errorString, function, result, wasThrown, savedResultIndex); |
pfeldman@chromium.org | 654a83d | 2011-01-19 09:00:58 +0000 | [diff] [blame] | 82 | } |
yurys@chromium.org | 774d8db | 2010-03-31 15:24:19 +0000 | [diff] [blame] | 83 | |
drousso@apple.com | 8a0bc01 | 2018-12-04 09:08:42 +0000 | [diff] [blame] | 84 | void InjectedScript::awaitPromise(const String& promiseObjectId, bool returnByValue, bool generatePreview, bool saveResult, AsyncCallCallback&& callback) |
| 85 | { |
| 86 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "awaitPromise"_s, inspectorEnvironment()->functionCallHandler()); |
| 87 | function.appendArgument(promiseObjectId); |
| 88 | function.appendArgument(returnByValue); |
| 89 | function.appendArgument(generatePreview); |
| 90 | function.appendArgument(saveResult); |
| 91 | makeAsyncCall(function, WTFMove(callback)); |
| 92 | } |
| 93 | |
darin@apple.com | a4ddc78 | 2021-05-30 16:11:40 +0000 | [diff] [blame] | 94 | void InjectedScript::callFunctionOn(Protocol::ErrorString& errorString, const String& objectId, const String& expression, const String& arguments, bool returnByValue, bool generatePreview, RefPtr<Protocol::Runtime::RemoteObject>& result, std::optional<bool>& wasThrown) |
pfeldman@chromium.org | ad390c6 | 2011-03-02 17:39:48 +0000 | [diff] [blame] | 95 | { |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 96 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "callFunctionOn"_s, inspectorEnvironment()->functionCallHandler()); |
pfeldman@chromium.org | 7827856 | 2011-03-21 07:42:31 +0000 | [diff] [blame] | 97 | function.appendArgument(objectId); |
pfeldman@chromium.org | ad390c6 | 2011-03-02 17:39:48 +0000 | [diff] [blame] | 98 | function.appendArgument(expression); |
pfeldman@chromium.org | 19665e8 | 2011-07-26 10:09:52 +0000 | [diff] [blame] | 99 | function.appendArgument(arguments); |
pfeldman@chromium.org | f40526f | 2011-08-04 16:09:00 +0000 | [diff] [blame] | 100 | function.appendArgument(returnByValue); |
yurys@chromium.org | c3ce094 | 2012-11-01 12:17:00 +0000 | [diff] [blame] | 101 | function.appendArgument(generatePreview); |
drousso@apple.com | 8a0bc01 | 2018-12-04 09:08:42 +0000 | [diff] [blame] | 102 | |
darin@apple.com | a4ddc78 | 2021-05-30 16:11:40 +0000 | [diff] [blame] | 103 | std::optional<int> savedResultIndex; |
drousso@apple.com | 8a0bc01 | 2018-12-04 09:08:42 +0000 | [diff] [blame] | 104 | makeEvalCall(errorString, function, result, wasThrown, savedResultIndex); |
| 105 | ASSERT(!savedResultIndex); |
pfeldman@chromium.org | ad390c6 | 2011-03-02 17:39:48 +0000 | [diff] [blame] | 106 | } |
| 107 | |
darin@apple.com | a4ddc78 | 2021-05-30 16:11:40 +0000 | [diff] [blame] | 108 | void InjectedScript::evaluateOnCallFrame(Protocol::ErrorString& errorString, JSC::JSValue callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, bool saveResult, RefPtr<Protocol::Runtime::RemoteObject>& result, std::optional<bool>& wasThrown, std::optional<int>& savedResultIndex) |
pfeldman@chromium.org | 654a83d | 2011-01-19 09:00:58 +0000 | [diff] [blame] | 109 | { |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 110 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "evaluateOnCallFrame"_s, inspectorEnvironment()->functionCallHandler()); |
yurys@chromium.org | 83c5e07 | 2011-04-27 08:55:09 +0000 | [diff] [blame] | 111 | function.appendArgument(callFrames); |
pfeldman@chromium.org | 7827856 | 2011-03-21 07:42:31 +0000 | [diff] [blame] | 112 | function.appendArgument(callFrameId); |
pfeldman@chromium.org | 654a83d | 2011-01-19 09:00:58 +0000 | [diff] [blame] | 113 | function.appendArgument(expression); |
| 114 | function.appendArgument(objectGroup); |
pfeldman@chromium.org | 9c856a3 | 2011-01-26 10:19:04 +0000 | [diff] [blame] | 115 | function.appendArgument(includeCommandLineAPI); |
pfeldman@chromium.org | f645806 | 2011-08-10 14:37:23 +0000 | [diff] [blame] | 116 | function.appendArgument(returnByValue); |
yurys@chromium.org | c3ce094 | 2012-11-01 12:17:00 +0000 | [diff] [blame] | 117 | function.appendArgument(generatePreview); |
joepeck@webkit.org | 029930dd | 2015-02-27 01:15:23 +0000 | [diff] [blame] | 118 | function.appendArgument(saveResult); |
| 119 | makeEvalCall(errorString, function, result, wasThrown, savedResultIndex); |
pfeldman@chromium.org | 654a83d | 2011-01-19 09:00:58 +0000 | [diff] [blame] | 120 | } |
| 121 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 122 | void InjectedScript::getFunctionDetails(Protocol::ErrorString& errorString, const String& functionId, RefPtr<Protocol::Debugger::FunctionDetails>& result) |
yurys@chromium.org | 0114f05 | 2011-11-14 09:27:25 +0000 | [diff] [blame] | 123 | { |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 124 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "getFunctionDetails"_s, inspectorEnvironment()->functionCallHandler()); |
yurys@chromium.org | 0114f05 | 2011-11-14 09:27:25 +0000 | [diff] [blame] | 125 | function.appendArgument(functionId); |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 126 | |
bburg@apple.com | 3d71571 | 2017-12-12 21:49:13 +0000 | [diff] [blame] | 127 | RefPtr<JSON::Value> resultValue = makeCall(function); |
bburg@apple.com | 61f04d6 | 2017-11-28 19:58:16 +0000 | [diff] [blame] | 128 | if (!resultValue || resultValue->type() != JSON::Value::Type::Object) { |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 129 | errorString = resultValue->asString(); |
| 130 | if (!errorString) |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 131 | errorString = "Internal error"_s; |
yurys@chromium.org | 0114f05 | 2011-11-14 09:27:25 +0000 | [diff] [blame] | 132 | return; |
| 133 | } |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 134 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 135 | result = Protocol::BindingTraits<Protocol::Debugger::FunctionDetails>::runtimeCast(resultValue.releaseNonNull()); |
yurys@chromium.org | 0114f05 | 2011-11-14 09:27:25 +0000 | [diff] [blame] | 136 | } |
| 137 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 138 | void InjectedScript::functionDetails(Protocol::ErrorString& errorString, JSC::JSValue value, RefPtr<Protocol::Debugger::FunctionDetails>& result) |
commit-queue@webkit.org | 46f46f2 | 2016-03-10 06:15:25 +0000 | [diff] [blame] | 139 | { |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 140 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "functionDetails"_s, inspectorEnvironment()->functionCallHandler()); |
commit-queue@webkit.org | 46f46f2 | 2016-03-10 06:15:25 +0000 | [diff] [blame] | 141 | function.appendArgument(value); |
commit-queue@webkit.org | 46f46f2 | 2016-03-10 06:15:25 +0000 | [diff] [blame] | 142 | |
bburg@apple.com | 3d71571 | 2017-12-12 21:49:13 +0000 | [diff] [blame] | 143 | RefPtr<JSON::Value> resultValue = makeCall(function); |
bburg@apple.com | 61f04d6 | 2017-11-28 19:58:16 +0000 | [diff] [blame] | 144 | if (!resultValue || resultValue->type() != JSON::Value::Type::Object) { |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 145 | errorString = resultValue->asString(); |
| 146 | if (!errorString) |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 147 | errorString = "Internal error"_s; |
commit-queue@webkit.org | 46f46f2 | 2016-03-10 06:15:25 +0000 | [diff] [blame] | 148 | return; |
| 149 | } |
| 150 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 151 | result = Protocol::BindingTraits<Protocol::Debugger::FunctionDetails>::runtimeCast(resultValue.releaseNonNull()); |
commit-queue@webkit.org | 46f46f2 | 2016-03-10 06:15:25 +0000 | [diff] [blame] | 152 | } |
| 153 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 154 | void InjectedScript::getPreview(Protocol::ErrorString& errorString, const String& objectId, RefPtr<Protocol::Runtime::ObjectPreview>& result) |
joepeck@webkit.org | 34919fc | 2017-06-22 21:12:01 +0000 | [diff] [blame] | 155 | { |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 156 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "getPreview"_s, inspectorEnvironment()->functionCallHandler()); |
joepeck@webkit.org | 34919fc | 2017-06-22 21:12:01 +0000 | [diff] [blame] | 157 | function.appendArgument(objectId); |
| 158 | |
bburg@apple.com | 3d71571 | 2017-12-12 21:49:13 +0000 | [diff] [blame] | 159 | RefPtr<JSON::Value> resultValue = makeCall(function); |
bburg@apple.com | 61f04d6 | 2017-11-28 19:58:16 +0000 | [diff] [blame] | 160 | if (!resultValue || resultValue->type() != JSON::Value::Type::Object) { |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 161 | errorString = resultValue->asString(); |
| 162 | if (!errorString) |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 163 | errorString = "Internal error"_s; |
joepeck@webkit.org | 34919fc | 2017-06-22 21:12:01 +0000 | [diff] [blame] | 164 | return; |
| 165 | } |
| 166 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 167 | result = Protocol::BindingTraits<Protocol::Runtime::ObjectPreview>::runtimeCast(resultValue.releaseNonNull()); |
joepeck@webkit.org | 34919fc | 2017-06-22 21:12:01 +0000 | [diff] [blame] | 168 | } |
| 169 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 170 | void InjectedScript::getProperties(Protocol::ErrorString& errorString, const String& objectId, bool ownProperties, int fetchStart, int fetchCount, bool generatePreview, RefPtr<JSON::ArrayOf<Protocol::Runtime::PropertyDescriptor>>& properties) |
pfeldman@chromium.org | 654a83d | 2011-01-19 09:00:58 +0000 | [diff] [blame] | 171 | { |
drousso@apple.com | eb74803 | 2019-09-19 05:58:27 +0000 | [diff] [blame] | 172 | ASSERT(fetchStart >= 0); |
| 173 | ASSERT(fetchCount >= 0); |
| 174 | |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 175 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "getProperties"_s, inspectorEnvironment()->functionCallHandler()); |
pfeldman@chromium.org | 7827856 | 2011-03-21 07:42:31 +0000 | [diff] [blame] | 176 | function.appendArgument(objectId); |
pfeldman@chromium.org | 6da2ce1 | 2011-08-10 13:41:30 +0000 | [diff] [blame] | 177 | function.appendArgument(ownProperties); |
drousso@apple.com | eb74803 | 2019-09-19 05:58:27 +0000 | [diff] [blame] | 178 | function.appendArgument(fetchStart); |
| 179 | function.appendArgument(fetchCount); |
joepeck@webkit.org | 1af2d8d | 2015-02-25 00:31:42 +0000 | [diff] [blame] | 180 | function.appendArgument(generatePreview); |
| 181 | |
bburg@apple.com | 3d71571 | 2017-12-12 21:49:13 +0000 | [diff] [blame] | 182 | RefPtr<JSON::Value> result = makeCall(function); |
bburg@apple.com | 61f04d6 | 2017-11-28 19:58:16 +0000 | [diff] [blame] | 183 | if (!result || result->type() != JSON::Value::Type::Array) { |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 184 | errorString = "Internal error"_s; |
joepeck@webkit.org | 1af2d8d | 2015-02-25 00:31:42 +0000 | [diff] [blame] | 185 | return; |
| 186 | } |
| 187 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 188 | properties = Protocol::BindingTraits<JSON::ArrayOf<Protocol::Runtime::PropertyDescriptor>>::runtimeCast(result.releaseNonNull()); |
joepeck@webkit.org | 1af2d8d | 2015-02-25 00:31:42 +0000 | [diff] [blame] | 189 | } |
| 190 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 191 | void InjectedScript::getDisplayableProperties(Protocol::ErrorString& errorString, const String& objectId, int fetchStart, int fetchCount, bool generatePreview, RefPtr<JSON::ArrayOf<Protocol::Runtime::PropertyDescriptor>>& properties) |
joepeck@webkit.org | 1af2d8d | 2015-02-25 00:31:42 +0000 | [diff] [blame] | 192 | { |
drousso@apple.com | eb74803 | 2019-09-19 05:58:27 +0000 | [diff] [blame] | 193 | ASSERT(fetchStart >= 0); |
| 194 | ASSERT(fetchCount >= 0); |
| 195 | |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 196 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "getDisplayableProperties"_s, inspectorEnvironment()->functionCallHandler()); |
joepeck@webkit.org | 1af2d8d | 2015-02-25 00:31:42 +0000 | [diff] [blame] | 197 | function.appendArgument(objectId); |
drousso@apple.com | eb74803 | 2019-09-19 05:58:27 +0000 | [diff] [blame] | 198 | function.appendArgument(fetchStart); |
| 199 | function.appendArgument(fetchCount); |
commit-queue@webkit.org | 4b254d6 | 2015-02-22 03:50:34 +0000 | [diff] [blame] | 200 | function.appendArgument(generatePreview); |
pfeldman@chromium.org | e573fa3 | 2011-03-17 18:10:15 +0000 | [diff] [blame] | 201 | |
bburg@apple.com | 3d71571 | 2017-12-12 21:49:13 +0000 | [diff] [blame] | 202 | RefPtr<JSON::Value> result = makeCall(function); |
bburg@apple.com | 61f04d6 | 2017-11-28 19:58:16 +0000 | [diff] [blame] | 203 | if (!result || result->type() != JSON::Value::Type::Array) { |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 204 | errorString = "Internal error"_s; |
pfeldman@chromium.org | e573fa3 | 2011-03-17 18:10:15 +0000 | [diff] [blame] | 205 | return; |
| 206 | } |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 207 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 208 | properties = Protocol::BindingTraits<JSON::ArrayOf<Protocol::Runtime::PropertyDescriptor>>::runtimeCast(result.releaseNonNull()); |
pfeldman@chromium.org | 654a83d | 2011-01-19 09:00:58 +0000 | [diff] [blame] | 209 | } |
| 210 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 211 | void InjectedScript::getInternalProperties(Protocol::ErrorString& errorString, const String& objectId, bool generatePreview, RefPtr<JSON::ArrayOf<Protocol::Runtime::InternalPropertyDescriptor>>& properties) |
commit-queue@webkit.org | c639f2b | 2012-10-04 16:12:42 +0000 | [diff] [blame] | 212 | { |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 213 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "getInternalProperties"_s, inspectorEnvironment()->functionCallHandler()); |
commit-queue@webkit.org | c639f2b | 2012-10-04 16:12:42 +0000 | [diff] [blame] | 214 | function.appendArgument(objectId); |
commit-queue@webkit.org | 4b254d6 | 2015-02-22 03:50:34 +0000 | [diff] [blame] | 215 | function.appendArgument(generatePreview); |
commit-queue@webkit.org | c639f2b | 2012-10-04 16:12:42 +0000 | [diff] [blame] | 216 | |
bburg@apple.com | 3d71571 | 2017-12-12 21:49:13 +0000 | [diff] [blame] | 217 | RefPtr<JSON::Value> result = makeCall(function); |
bburg@apple.com | 61f04d6 | 2017-11-28 19:58:16 +0000 | [diff] [blame] | 218 | if (!result || result->type() != JSON::Value::Type::Array) { |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 219 | errorString = "Internal error"_s; |
commit-queue@webkit.org | c639f2b | 2012-10-04 16:12:42 +0000 | [diff] [blame] | 220 | return; |
| 221 | } |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 222 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 223 | auto array = Protocol::BindingTraits<JSON::ArrayOf<Protocol::Runtime::InternalPropertyDescriptor>>::runtimeCast(result.releaseNonNull()); |
| 224 | if (array->length()) |
| 225 | properties = WTFMove(array); |
joepeck@webkit.org | 763bbbd | 2015-01-29 19:25:16 +0000 | [diff] [blame] | 226 | } |
| 227 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 228 | void InjectedScript::getCollectionEntries(Protocol::ErrorString& errorString, const String& objectId, const String& objectGroup, int fetchStart, int fetchCount, RefPtr<JSON::ArrayOf<Protocol::Runtime::CollectionEntry>>& entries) |
joepeck@webkit.org | 763bbbd | 2015-01-29 19:25:16 +0000 | [diff] [blame] | 229 | { |
drousso@apple.com | eb74803 | 2019-09-19 05:58:27 +0000 | [diff] [blame] | 230 | ASSERT(fetchStart >= 0); |
| 231 | ASSERT(fetchCount >= 0); |
| 232 | |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 233 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "getCollectionEntries"_s, inspectorEnvironment()->functionCallHandler()); |
joepeck@webkit.org | 763bbbd | 2015-01-29 19:25:16 +0000 | [diff] [blame] | 234 | function.appendArgument(objectId); |
| 235 | function.appendArgument(objectGroup); |
drousso@apple.com | eb74803 | 2019-09-19 05:58:27 +0000 | [diff] [blame] | 236 | function.appendArgument(fetchStart); |
| 237 | function.appendArgument(fetchCount); |
joepeck@webkit.org | 763bbbd | 2015-01-29 19:25:16 +0000 | [diff] [blame] | 238 | |
bburg@apple.com | 3d71571 | 2017-12-12 21:49:13 +0000 | [diff] [blame] | 239 | RefPtr<JSON::Value> result = makeCall(function); |
bburg@apple.com | 61f04d6 | 2017-11-28 19:58:16 +0000 | [diff] [blame] | 240 | if (!result || result->type() != JSON::Value::Type::Array) { |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 241 | errorString = "Internal error"_s; |
joepeck@webkit.org | 763bbbd | 2015-01-29 19:25:16 +0000 | [diff] [blame] | 242 | return; |
| 243 | } |
| 244 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 245 | entries = Protocol::BindingTraits<JSON::ArrayOf<Protocol::Runtime::CollectionEntry>>::runtimeCast(result.releaseNonNull()); |
commit-queue@webkit.org | c639f2b | 2012-10-04 16:12:42 +0000 | [diff] [blame] | 246 | } |
| 247 | |
darin@apple.com | a4ddc78 | 2021-05-30 16:11:40 +0000 | [diff] [blame] | 248 | void InjectedScript::saveResult(Protocol::ErrorString& errorString, const String& callArgumentJSON, std::optional<int>& savedResultIndex) |
joepeck@webkit.org | cc05b50 | 2015-03-03 02:24:49 +0000 | [diff] [blame] | 249 | { |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 250 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "saveResult"_s, inspectorEnvironment()->functionCallHandler()); |
joepeck@webkit.org | cc05b50 | 2015-03-03 02:24:49 +0000 | [diff] [blame] | 251 | function.appendArgument(callArgumentJSON); |
| 252 | |
bburg@apple.com | 3d71571 | 2017-12-12 21:49:13 +0000 | [diff] [blame] | 253 | RefPtr<JSON::Value> result = makeCall(function); |
bburg@apple.com | 61f04d6 | 2017-11-28 19:58:16 +0000 | [diff] [blame] | 254 | if (!result || result->type() != JSON::Value::Type::Integer) { |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 255 | errorString = "Internal error"_s; |
joepeck@webkit.org | cc05b50 | 2015-03-03 02:24:49 +0000 | [diff] [blame] | 256 | return; |
| 257 | } |
| 258 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 259 | savedResultIndex = result->asInteger(); |
joepeck@webkit.org | cc05b50 | 2015-03-03 02:24:49 +0000 | [diff] [blame] | 260 | } |
| 261 | |
darin@apple.com | 9c3ff98 | 2018-02-17 19:10:15 +0000 | [diff] [blame] | 262 | Ref<JSON::ArrayOf<Protocol::Debugger::CallFrame>> InjectedScript::wrapCallFrames(JSC::JSValue callFrames) const |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 263 | { |
| 264 | ASSERT(!hasNoValue()); |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 265 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "wrapCallFrames"_s, inspectorEnvironment()->functionCallHandler()); |
yurys@chromium.org | 83c5e07 | 2011-04-27 08:55:09 +0000 | [diff] [blame] | 266 | function.appendArgument(callFrames); |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 267 | |
drousso@apple.com | b6d9ffe | 2019-09-20 08:28:09 +0000 | [diff] [blame] | 268 | auto callResult = callFunctionWithEvalEnabled(function); |
| 269 | ASSERT(callResult); |
| 270 | if (!callResult || !callResult.value()) |
darin@apple.com | 9c3ff98 | 2018-02-17 19:10:15 +0000 | [diff] [blame] | 271 | return JSON::ArrayOf<Protocol::Debugger::CallFrame>::create(); |
drousso@apple.com | b6d9ffe | 2019-09-20 08:28:09 +0000 | [diff] [blame] | 272 | |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 273 | RefPtr<JSON::Value> result = toInspectorValue(globalObject(), callResult.value()); |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 274 | if (result && result->type() == JSON::Value::Type::Array) |
| 275 | return Protocol::BindingTraits<JSON::ArrayOf<Protocol::Debugger::CallFrame>>::runtimeCast(result.releaseNonNull()); |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 276 | |
darin@apple.com | 9c3ff98 | 2018-02-17 19:10:15 +0000 | [diff] [blame] | 277 | return JSON::ArrayOf<Protocol::Debugger::CallFrame>::create(); |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 278 | } |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 279 | |
darin@apple.com | 9c3ff98 | 2018-02-17 19:10:15 +0000 | [diff] [blame] | 280 | RefPtr<Protocol::Runtime::RemoteObject> InjectedScript::wrapObject(JSC::JSValue value, const String& groupName, bool generatePreview) const |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 281 | { |
| 282 | ASSERT(!hasNoValue()); |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 283 | Deprecated::ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapObject"_s, inspectorEnvironment()->functionCallHandler()); |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 284 | wrapFunction.appendArgument(value); |
pfeldman@chromium.org | ad390c6 | 2011-03-02 17:39:48 +0000 | [diff] [blame] | 285 | wrapFunction.appendArgument(groupName); |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 286 | wrapFunction.appendArgument(hasAccessToInspectedScriptState()); |
pfeldman@chromium.org | 279884b | 2012-08-09 15:13:56 +0000 | [diff] [blame] | 287 | wrapFunction.appendArgument(generatePreview); |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 288 | |
drousso@apple.com | b6d9ffe | 2019-09-20 08:28:09 +0000 | [diff] [blame] | 289 | auto callResult = callFunctionWithEvalEnabled(wrapFunction); |
| 290 | if (!callResult) |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 291 | return nullptr; |
| 292 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 293 | auto resultValue = toInspectorValue(globalObject(), callResult.value()); |
| 294 | if (!resultValue) |
| 295 | return nullptr; |
burg@cs.washington.edu | ba2d103 | 2014-09-30 03:30:54 +0000 | [diff] [blame] | 296 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 297 | auto resultObject = resultValue->asObject(); |
| 298 | if (!resultObject) |
| 299 | return nullptr; |
| 300 | |
| 301 | return Protocol::BindingTraits<Protocol::Runtime::RemoteObject>::runtimeCast(resultObject.releaseNonNull()); |
pfeldman@chromium.org | c226870 | 2013-02-18 10:51:37 +0000 | [diff] [blame] | 302 | } |
| 303 | |
eric.carlson@apple.com | 5a5e76a | 2017-12-12 00:41:54 +0000 | [diff] [blame] | 304 | RefPtr<Protocol::Runtime::RemoteObject> InjectedScript::wrapJSONString(const String& json, const String& groupName, bool generatePreview) const |
| 305 | { |
| 306 | ASSERT(!hasNoValue()); |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 307 | Deprecated::ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapJSONString"_s, inspectorEnvironment()->functionCallHandler()); |
eric.carlson@apple.com | 5a5e76a | 2017-12-12 00:41:54 +0000 | [diff] [blame] | 308 | wrapFunction.appendArgument(json); |
| 309 | wrapFunction.appendArgument(groupName); |
| 310 | wrapFunction.appendArgument(generatePreview); |
| 311 | |
drousso@apple.com | b6d9ffe | 2019-09-20 08:28:09 +0000 | [diff] [blame] | 312 | auto callResult = callFunctionWithEvalEnabled(wrapFunction); |
| 313 | if (!callResult) |
eric.carlson@apple.com | 5a5e76a | 2017-12-12 00:41:54 +0000 | [diff] [blame] | 314 | return nullptr; |
| 315 | |
drousso@apple.com | b6d9ffe | 2019-09-20 08:28:09 +0000 | [diff] [blame] | 316 | if (callResult.value().isNull()) |
eric.carlson@apple.com | 5a5e76a | 2017-12-12 00:41:54 +0000 | [diff] [blame] | 317 | return nullptr; |
| 318 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 319 | auto resultValue = toInspectorValue(globalObject(), callResult.value()); |
| 320 | if (!resultValue) |
| 321 | return nullptr; |
eric.carlson@apple.com | 5a5e76a | 2017-12-12 00:41:54 +0000 | [diff] [blame] | 322 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 323 | auto resultObject = resultValue->asObject(); |
| 324 | if (!resultObject) |
| 325 | return nullptr; |
| 326 | |
| 327 | return Protocol::BindingTraits<Protocol::Runtime::RemoteObject>::runtimeCast(resultObject.releaseNonNull()); |
eric.carlson@apple.com | 5a5e76a | 2017-12-12 00:41:54 +0000 | [diff] [blame] | 328 | } |
| 329 | |
darin@apple.com | 9c3ff98 | 2018-02-17 19:10:15 +0000 | [diff] [blame] | 330 | RefPtr<Protocol::Runtime::RemoteObject> InjectedScript::wrapTable(JSC::JSValue table, JSC::JSValue columns) const |
pfeldman@chromium.org | c226870 | 2013-02-18 10:51:37 +0000 | [diff] [blame] | 331 | { |
| 332 | ASSERT(!hasNoValue()); |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 333 | Deprecated::ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapTable"_s, inspectorEnvironment()->functionCallHandler()); |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 334 | wrapFunction.appendArgument(hasAccessToInspectedScriptState()); |
pfeldman@chromium.org | c226870 | 2013-02-18 10:51:37 +0000 | [diff] [blame] | 335 | wrapFunction.appendArgument(table); |
darin@apple.com | 6be924b | 2016-04-16 02:25:56 +0000 | [diff] [blame] | 336 | if (!columns) |
pfeldman@chromium.org | c226870 | 2013-02-18 10:51:37 +0000 | [diff] [blame] | 337 | wrapFunction.appendArgument(false); |
| 338 | else |
| 339 | wrapFunction.appendArgument(columns); |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 340 | |
drousso@apple.com | b6d9ffe | 2019-09-20 08:28:09 +0000 | [diff] [blame] | 341 | auto callResult = callFunctionWithEvalEnabled(wrapFunction); |
| 342 | if (!callResult) |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 343 | return nullptr; |
| 344 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 345 | auto resultValue = toInspectorValue(globalObject(), callResult.value()); |
| 346 | if (!resultValue) |
| 347 | return nullptr; |
burg@cs.washington.edu | ba2d103 | 2014-09-30 03:30:54 +0000 | [diff] [blame] | 348 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 349 | auto resultObject = resultValue->asObject(); |
| 350 | if (!resultObject) |
| 351 | return nullptr; |
| 352 | |
| 353 | return Protocol::BindingTraits<Protocol::Runtime::RemoteObject>::runtimeCast(resultObject.releaseNonNull()); |
pfeldman@chromium.org | 351b1a9 | 2011-02-24 14:43:25 +0000 | [diff] [blame] | 354 | } |
| 355 | |
darin@apple.com | 9c3ff98 | 2018-02-17 19:10:15 +0000 | [diff] [blame] | 356 | RefPtr<Protocol::Runtime::ObjectPreview> InjectedScript::previewValue(JSC::JSValue value) const |
commit-queue@webkit.org | 46f46f2 | 2016-03-10 06:15:25 +0000 | [diff] [blame] | 357 | { |
| 358 | ASSERT(!hasNoValue()); |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 359 | Deprecated::ScriptFunctionCall wrapFunction(injectedScriptObject(), "previewValue"_s, inspectorEnvironment()->functionCallHandler()); |
commit-queue@webkit.org | 46f46f2 | 2016-03-10 06:15:25 +0000 | [diff] [blame] | 360 | wrapFunction.appendArgument(value); |
| 361 | |
drousso@apple.com | b6d9ffe | 2019-09-20 08:28:09 +0000 | [diff] [blame] | 362 | auto callResult = callFunctionWithEvalEnabled(wrapFunction); |
| 363 | if (!callResult) |
commit-queue@webkit.org | 46f46f2 | 2016-03-10 06:15:25 +0000 | [diff] [blame] | 364 | return nullptr; |
| 365 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 366 | auto resultValue = toInspectorValue(globalObject(), callResult.value()); |
| 367 | if (!resultValue) |
| 368 | return nullptr; |
commit-queue@webkit.org | 46f46f2 | 2016-03-10 06:15:25 +0000 | [diff] [blame] | 369 | |
drousso@apple.com | 7b9e709 | 2020-09-10 19:23:17 +0000 | [diff] [blame] | 370 | auto resultObject = resultValue->asObject(); |
| 371 | if (!resultObject) |
| 372 | return nullptr; |
| 373 | |
| 374 | return Protocol::BindingTraits<Protocol::Runtime::ObjectPreview>::runtimeCast(resultObject.releaseNonNull()); |
commit-queue@webkit.org | 46f46f2 | 2016-03-10 06:15:25 +0000 | [diff] [blame] | 375 | } |
| 376 | |
drousso@apple.com | 926dd97 | 2019-03-19 19:31:31 +0000 | [diff] [blame] | 377 | void InjectedScript::setEventValue(JSC::JSValue value) |
| 378 | { |
| 379 | ASSERT(!hasNoValue()); |
| 380 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "setEventValue"_s, inspectorEnvironment()->functionCallHandler()); |
| 381 | function.appendArgument(value); |
| 382 | makeCall(function); |
| 383 | } |
| 384 | |
| 385 | void InjectedScript::clearEventValue() |
| 386 | { |
| 387 | ASSERT(!hasNoValue()); |
| 388 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "clearEventValue"_s, inspectorEnvironment()->functionCallHandler()); |
| 389 | makeCall(function); |
| 390 | } |
| 391 | |
darin@apple.com | 6be924b | 2016-04-16 02:25:56 +0000 | [diff] [blame] | 392 | void InjectedScript::setExceptionValue(JSC::JSValue value) |
joepeck@webkit.org | de4d1cf | 2014-11-19 23:49:36 +0000 | [diff] [blame] | 393 | { |
| 394 | ASSERT(!hasNoValue()); |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 395 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "setExceptionValue"_s, inspectorEnvironment()->functionCallHandler()); |
joepeck@webkit.org | de4d1cf | 2014-11-19 23:49:36 +0000 | [diff] [blame] | 396 | function.appendArgument(value); |
bburg@apple.com | 3d71571 | 2017-12-12 21:49:13 +0000 | [diff] [blame] | 397 | makeCall(function); |
joepeck@webkit.org | de4d1cf | 2014-11-19 23:49:36 +0000 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | void InjectedScript::clearExceptionValue() |
| 401 | { |
| 402 | ASSERT(!hasNoValue()); |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 403 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "clearExceptionValue"_s, inspectorEnvironment()->functionCallHandler()); |
bburg@apple.com | 3d71571 | 2017-12-12 21:49:13 +0000 | [diff] [blame] | 404 | makeCall(function); |
joepeck@webkit.org | de4d1cf | 2014-11-19 23:49:36 +0000 | [diff] [blame] | 405 | } |
| 406 | |
darin@apple.com | 6be924b | 2016-04-16 02:25:56 +0000 | [diff] [blame] | 407 | JSC::JSValue InjectedScript::findObjectById(const String& objectId) const |
yurys@chromium.org | 503c0f8 | 2012-05-11 15:05:42 +0000 | [diff] [blame] | 408 | { |
| 409 | ASSERT(!hasNoValue()); |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 410 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "findObjectById"_s, inspectorEnvironment()->functionCallHandler()); |
yurys@chromium.org | 503c0f8 | 2012-05-11 15:05:42 +0000 | [diff] [blame] | 411 | function.appendArgument(objectId); |
| 412 | |
drousso@apple.com | b6d9ffe | 2019-09-20 08:28:09 +0000 | [diff] [blame] | 413 | auto callResult = callFunctionWithEvalEnabled(function); |
| 414 | ASSERT(callResult); |
| 415 | if (!callResult) |
| 416 | return { }; |
| 417 | return callResult.value(); |
yurys@chromium.org | 503c0f8 | 2012-05-11 15:05:42 +0000 | [diff] [blame] | 418 | } |
| 419 | |
darin@apple.com | 6be924b | 2016-04-16 02:25:56 +0000 | [diff] [blame] | 420 | void InjectedScript::inspectObject(JSC::JSValue value) |
pfeldman@chromium.org | 351b1a9 | 2011-02-24 14:43:25 +0000 | [diff] [blame] | 421 | { |
| 422 | ASSERT(!hasNoValue()); |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 423 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "inspectObject"_s, inspectorEnvironment()->functionCallHandler()); |
commit-queue@webkit.org | c15383f | 2013-12-21 02:47:10 +0000 | [diff] [blame] | 424 | function.appendArgument(value); |
bburg@apple.com | 3d71571 | 2017-12-12 21:49:13 +0000 | [diff] [blame] | 425 | makeCall(function); |
commit-queue@webkit.org | c15383f | 2013-12-21 02:47:10 +0000 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | void InjectedScript::releaseObject(const String& objectId) |
| 429 | { |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 430 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "releaseObject"_s, inspectorEnvironment()->functionCallHandler()); |
commit-queue@webkit.org | c15383f | 2013-12-21 02:47:10 +0000 | [diff] [blame] | 431 | function.appendArgument(objectId); |
bburg@apple.com | 3d71571 | 2017-12-12 21:49:13 +0000 | [diff] [blame] | 432 | makeCall(function); |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 433 | } |
| 434 | |
loislo@chromium.org | d7d49c2 | 2011-03-04 15:05:59 +0000 | [diff] [blame] | 435 | void InjectedScript::releaseObjectGroup(const String& objectGroup) |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 436 | { |
| 437 | ASSERT(!hasNoValue()); |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 438 | Deprecated::ScriptFunctionCall releaseFunction(injectedScriptObject(), "releaseObjectGroup"_s, inspectorEnvironment()->functionCallHandler()); |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 439 | releaseFunction.appendArgument(objectGroup); |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 440 | |
drousso@apple.com | b6d9ffe | 2019-09-20 08:28:09 +0000 | [diff] [blame] | 441 | auto callResult = callFunctionWithEvalEnabled(releaseFunction); |
| 442 | ASSERT_UNUSED(callResult, callResult); |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 443 | } |
pfeldman@chromium.org | 654a83d | 2011-01-19 09:00:58 +0000 | [diff] [blame] | 444 | |
drousso@apple.com | ddfe77b | 2020-10-27 06:39:08 +0000 | [diff] [blame] | 445 | JSC::JSObject* InjectedScript::createCommandLineAPIObject(JSC::JSValue callFrame) const |
| 446 | { |
| 447 | ASSERT(!hasNoValue()); |
| 448 | Deprecated::ScriptFunctionCall function(injectedScriptObject(), "createCommandLineAPIObject"_s, inspectorEnvironment()->functionCallHandler()); |
| 449 | function.appendArgument(callFrame); |
| 450 | |
| 451 | auto callResult = callFunctionWithEvalEnabled(function); |
| 452 | ASSERT(callResult); |
| 453 | return callResult ? asObject(callResult.value()) : nullptr; |
| 454 | } |
| 455 | |
drousso@apple.com | 3a3286d | 2019-01-15 08:25:33 +0000 | [diff] [blame] | 456 | JSC::JSValue InjectedScript::arrayFromVector(Vector<JSC::JSValue>&& vector) |
| 457 | { |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 458 | JSC::JSGlobalObject* globalObject = this->globalObject(); |
| 459 | if (!globalObject) |
drousso@apple.com | 3a3286d | 2019-01-15 08:25:33 +0000 | [diff] [blame] | 460 | return JSC::jsUndefined(); |
| 461 | |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 462 | JSC::JSLockHolder lock(globalObject); |
drousso@apple.com | 3a3286d | 2019-01-15 08:25:33 +0000 | [diff] [blame] | 463 | |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 464 | JSC::JSArray* array = JSC::constructEmptyArray(globalObject, nullptr); |
drousso@apple.com | 3a3286d | 2019-01-15 08:25:33 +0000 | [diff] [blame] | 465 | if (!array) |
| 466 | return JSC::jsUndefined(); |
| 467 | |
| 468 | for (auto& item : vector) |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 469 | array->putDirectIndex(globalObject, array->length(), item); |
drousso@apple.com | 3a3286d | 2019-01-15 08:25:33 +0000 | [diff] [blame] | 470 | |
| 471 | return array; |
| 472 | } |
| 473 | |
joepeck@webkit.org | 69a4eaf | 2014-01-09 19:00:48 +0000 | [diff] [blame] | 474 | } // namespace Inspector |
yurys@chromium.org | 3cd7710 | 2010-02-04 09:38:40 +0000 | [diff] [blame] | 475 | |