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

Side by Side Diff: Source/core/testing/Internals.cpp

Issue 197213007: ScriptPromise implementation for V8 Promises (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/testing/Internals.h ('k') | Source/core/testing/Internals.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 24 matching lines...) Expand all
35 #include "LayerRect.h" 35 #include "LayerRect.h"
36 #include "LayerRectList.h" 36 #include "LayerRectList.h"
37 #include "MallocStatistics.h" 37 #include "MallocStatistics.h"
38 #include "MockPagePopupDriver.h" 38 #include "MockPagePopupDriver.h"
39 #include "RuntimeEnabledFeatures.h" 39 #include "RuntimeEnabledFeatures.h"
40 #include "TypeConversions.h" 40 #include "TypeConversions.h"
41 #include "bindings/v8/ExceptionMessages.h" 41 #include "bindings/v8/ExceptionMessages.h"
42 #include "bindings/v8/ExceptionState.h" 42 #include "bindings/v8/ExceptionState.h"
43 #include "bindings/v8/ScriptFunction.h" 43 #include "bindings/v8/ScriptFunction.h"
44 #include "bindings/v8/ScriptPromise.h" 44 #include "bindings/v8/ScriptPromise.h"
45 #include "bindings/v8/ScriptPromiseResolver.h"
45 #include "bindings/v8/SerializedScriptValue.h" 46 #include "bindings/v8/SerializedScriptValue.h"
46 #include "bindings/v8/V8ThrowException.h" 47 #include "bindings/v8/V8ThrowException.h"
47 #include "core/animation/DocumentTimeline.h" 48 #include "core/animation/DocumentTimeline.h"
48 #include "core/css/StyleSheetContents.h" 49 #include "core/css/StyleSheetContents.h"
49 #include "core/css/resolver/StyleResolver.h" 50 #include "core/css/resolver/StyleResolver.h"
50 #include "core/css/resolver/StyleResolverStats.h" 51 #include "core/css/resolver/StyleResolverStats.h"
51 #include "core/css/resolver/ViewportStyleResolver.h" 52 #include "core/css/resolver/ViewportStyleResolver.h"
52 #include "core/dom/ClientRect.h" 53 #include "core/dom/ClientRect.h"
53 #include "core/dom/ClientRectList.h" 54 #include "core/dom/ClientRectList.h"
54 #include "core/dom/DOMStringList.h" 55 #include "core/dom/DOMStringList.h"
(...skipping 2318 matching lines...) Expand 10 before | Expand all | Expand 10 after
2373 v8::Isolate* isolate = value.isolate(); 2374 v8::Isolate* isolate = value.isolate();
2374 ASSERT(v8Value->IsNumber()); 2375 ASSERT(v8Value->IsNumber());
2375 int intValue = v8Value.As<v8::Integer>()->Value(); 2376 int intValue = v8Value.As<v8::Integer>()->Value();
2376 ScriptValue result = ScriptValue(v8::Integer::New(isolate, intValue + 1 ), isolate); 2377 ScriptValue result = ScriptValue(v8::Integer::New(isolate, intValue + 1 ), isolate);
2377 return result; 2378 return result;
2378 } 2379 }
2379 }; 2380 };
2380 2381
2381 } // namespace 2382 } // namespace
2382 2383
2384 ScriptPromise Internals::createPromise(ExecutionContext* context)
2385 {
2386 return ScriptPromiseResolver::create(context)->promise();
2387 }
2388
2389 ScriptPromise Internals::createResolvedPromise(ExecutionContext* context, Script Value value)
2390 {
2391 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(conte xt);
2392 ScriptPromise promise = resolver->promise();
2393 resolver->resolve(value);
2394 return promise;
2395 }
2396
2397 ScriptPromise Internals::createRejectedPromise(ExecutionContext* context, Script Value value)
2398 {
2399 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(conte xt);
2400 ScriptPromise promise = resolver->promise();
2401 resolver->reject(value);
2402 return promise;
2403 }
2404
2383 ScriptPromise Internals::addOneToPromise(ExecutionContext* context, ScriptPromis e promise) 2405 ScriptPromise Internals::addOneToPromise(ExecutionContext* context, ScriptPromis e promise)
2384 { 2406 {
2385 return promise.then(AddOneFunction::create(context)); 2407 return promise.then(AddOneFunction::create(context));
2386 } 2408 }
2387 2409
2388 void Internals::trace(Visitor* visitor) 2410 void Internals::trace(Visitor* visitor)
2389 { 2411 {
2390 visitor->trace(m_runtimeFlags); 2412 visitor->trace(m_runtimeFlags);
2391 visitor->trace(m_profilers); 2413 visitor->trace(m_profilers);
2392 } 2414 }
(...skipping 17 matching lines...) Expand all
2410 } 2432 }
2411 2433
2412 String Internals::textSurroundingNode(Node* node, int x, int y, unsigned long ma xLength) 2434 String Internals::textSurroundingNode(Node* node, int x, int y, unsigned long ma xLength)
2413 { 2435 {
2414 blink::WebPoint point(x, y); 2436 blink::WebPoint point(x, y);
2415 SurroundingText surroundingText(VisiblePosition(node->renderer()->positionFo rPoint(static_cast<IntPoint>(point))), maxLength); 2437 SurroundingText surroundingText(VisiblePosition(node->renderer()->positionFo rPoint(static_cast<IntPoint>(point))), maxLength);
2416 return surroundingText.content(); 2438 return surroundingText.content();
2417 } 2439 }
2418 2440
2419 } 2441 }
OLDNEW
« no previous file with comments | « Source/core/testing/Internals.h ('k') | Source/core/testing/Internals.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698