Index: components/test_runner/spell_check_client.cc |
diff --git a/components/test_runner/spell_check_client.cc b/components/test_runner/spell_check_client.cc |
index e9c450a479d041927c922ebb656c036797091a29..873e7771f1cd7d978af395b175959809f0b615c9 100644 |
--- a/components/test_runner/spell_check_client.cc |
+++ b/components/test_runner/spell_check_client.cc |
@@ -13,8 +13,11 @@ |
#include "components/test_runner/mock_grammar_check.h" |
#include "components/test_runner/test_runner.h" |
#include "components/test_runner/web_test_delegate.h" |
+#include "third_party/WebKit/public/web/WebFrame.h" |
+#include "third_party/WebKit/public/web/WebKit.h" |
#include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" |
#include "third_party/WebKit/public/web/WebTextCheckingResult.h" |
+#include "third_party/WebKit/public/web/WebView.h" |
namespace test_runner { |
@@ -36,6 +39,11 @@ void SpellCheckClient::SetEnabled(bool enabled) { |
enabled_ = enabled; |
} |
+void SpellCheckClient::Reset() { |
+ enabled_ = false; |
+ resolved_callback_.Reset(); |
+} |
+ |
// blink::WebSpellCheckClient |
void SpellCheckClient::spellCheck( |
const blink::WebString& text, |
@@ -58,13 +66,17 @@ void SpellCheckClient::requestCheckingOfText( |
const blink::WebVector<unsigned>& marker_offsets, |
blink::WebTextCheckingCompletion* completion) { |
if (!enabled_ || text.isEmpty()) { |
- if (completion) |
+ if (completion) { |
completion->didCancelCheckingText(); |
+ RequestResolved(); |
+ } |
return; |
} |
- if (last_requested_text_checking_completion_) |
+ if (last_requested_text_checking_completion_) { |
last_requested_text_checking_completion_->didCancelCheckingText(); |
+ RequestResolved(); |
+ } |
last_requested_text_checking_completion_ = completion; |
last_requested_text_check_string_ = text; |
@@ -115,9 +127,37 @@ void SpellCheckClient::FinishLastTextCheck() { |
} |
last_requested_text_checking_completion_->didFinishCheckingText(results); |
last_requested_text_checking_completion_ = 0; |
+ RequestResolved(); |
if (test_runner_->shouldDumpSpellCheckCallbacks()) |
delegate_->PrintMessage("SpellCheckEvent: FinishLastTextCheck\n"); |
} |
+void SpellCheckClient::SetSpellCheckResolvedCallback( |
+ v8::Local<v8::Function> callback) { |
+ resolved_callback_.Reset(blink::mainThreadIsolate(), callback); |
+} |
+ |
+void SpellCheckClient::RequestResolved() { |
+ if (resolved_callback_.IsEmpty()) |
+ return; |
+ |
+ v8::Isolate* isolate = blink::mainThreadIsolate(); |
+ v8::HandleScope handle_scope(isolate); |
+ |
+ blink::WebFrame* frame = test_runner_->main_view()->mainFrame(); |
+ if (!frame || frame->isWebRemoteFrame()) |
+ return; |
+ |
+ v8::Local<v8::Context> context = frame->mainWorldScriptContext(); |
+ if (context.IsEmpty()) |
+ return; |
+ |
+ v8::Context::Scope context_scope(context); |
+ |
+ frame->callFunctionEvenIfScriptDisabled( |
haraken
2016/12/20 02:46:21
Is there any reason you want to run scripts when s
Xiaocheng
2016/12/20 03:05:59
No specific reason. I just copied code from access
|
+ v8::Local<v8::Function>::New(isolate, resolved_callback_), |
+ context->Global(), 0, nullptr); |
+} |
+ |
} // namespace test_runner |