| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/fetch/ReadableStreamBytesConsumer.h" | 5 #include "modules/fetch/ReadableStreamBytesConsumer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "bindings/core/v8/V8BindingForCore.h" | 10 #include "bindings/core/v8/V8BindingForCore.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 ScriptState* GetScriptState() { | 51 ScriptState* GetScriptState() { |
| 52 return ToScriptStateForMainWorld(page_->GetDocument().GetFrame()); | 52 return ToScriptStateForMainWorld(page_->GetDocument().GetFrame()); |
| 53 } | 53 } |
| 54 v8::Isolate* GetIsolate() { return GetScriptState()->GetIsolate(); } | 54 v8::Isolate* GetIsolate() { return GetScriptState()->GetIsolate(); } |
| 55 | 55 |
| 56 v8::MaybeLocal<v8::Value> Eval(const char* s) { | 56 v8::MaybeLocal<v8::Value> Eval(const char* s) { |
| 57 v8::Local<v8::String> source; | 57 v8::Local<v8::String> source; |
| 58 v8::Local<v8::Script> script; | 58 v8::Local<v8::Script> script; |
| 59 v8::MicrotasksScope microtasks(GetIsolate(), | 59 v8::MicrotasksScope microtasks(GetIsolate(), |
| 60 v8::MicrotasksScope::kDoNotRunMicrotasks); | 60 v8::MicrotasksScope::kDoNotRunMicrotasks); |
| 61 if (!V8Call(v8::String::NewFromUtf8(GetIsolate(), s, | 61 if (!v8::String::NewFromUtf8(GetIsolate(), s, v8::NewStringType::kNormal) |
| 62 v8::NewStringType::kNormal), | 62 .ToLocal(&source)) { |
| 63 source)) { | |
| 64 ADD_FAILURE(); | 63 ADD_FAILURE(); |
| 65 return v8::MaybeLocal<v8::Value>(); | 64 return v8::MaybeLocal<v8::Value>(); |
| 66 } | 65 } |
| 67 if (!V8Call(v8::Script::Compile(GetScriptState()->GetContext(), source), | 66 if (!v8::Script::Compile(GetScriptState()->GetContext(), source) |
| 68 script)) { | 67 .ToLocal(&script)) { |
| 69 ADD_FAILURE() << "Compilation fails"; | 68 ADD_FAILURE() << "Compilation fails"; |
| 70 return v8::MaybeLocal<v8::Value>(); | 69 return v8::MaybeLocal<v8::Value>(); |
| 71 } | 70 } |
| 72 return script->Run(GetScriptState()->GetContext()); | 71 return script->Run(GetScriptState()->GetContext()); |
| 73 } | 72 } |
| 74 v8::MaybeLocal<v8::Value> EvalWithPrintingError(const char* s) { | 73 v8::MaybeLocal<v8::Value> EvalWithPrintingError(const char* s) { |
| 75 v8::TryCatch block(GetIsolate()); | 74 v8::TryCatch block(GetIsolate()); |
| 76 v8::MaybeLocal<v8::Value> r = Eval(s); | 75 v8::MaybeLocal<v8::Value> r = Eval(s); |
| 77 if (block.HasCaught()) { | 76 if (block.HasCaught()) { |
| 78 ADD_FAILURE() << ToCoreString(block.Exception()->ToString(GetIsolate())) | 77 ADD_FAILURE() << ToCoreString(block.Exception()->ToString(GetIsolate())) |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 checkpoint.Call(3); | 370 checkpoint.Call(3); |
| 372 testing::RunPendingTasks(); | 371 testing::RunPendingTasks(); |
| 373 checkpoint.Call(4); | 372 checkpoint.Call(4); |
| 374 EXPECT_EQ(PublicState::kErrored, consumer->GetPublicState()); | 373 EXPECT_EQ(PublicState::kErrored, consumer->GetPublicState()); |
| 375 EXPECT_EQ(Result::kError, consumer->BeginRead(&buffer, &available)); | 374 EXPECT_EQ(Result::kError, consumer->BeginRead(&buffer, &available)); |
| 376 } | 375 } |
| 377 | 376 |
| 378 } // namespace | 377 } // namespace |
| 379 | 378 |
| 380 } // namespace blink | 379 } // namespace blink |
| OLD | NEW |