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

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
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 2319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 v8::Isolate* isolate = value.isolate(); 2375 v8::Isolate* isolate = value.isolate();
2375 ASSERT(v8Value->IsNumber()); 2376 ASSERT(v8Value->IsNumber());
2376 int intValue = v8Value.As<v8::Integer>()->Value(); 2377 int intValue = v8Value.As<v8::Integer>()->Value();
2377 ScriptValue result = ScriptValue(v8::Integer::New(isolate, intValue + 1 ), isolate); 2378 ScriptValue result = ScriptValue(v8::Integer::New(isolate, intValue + 1 ), isolate);
2378 return result; 2379 return result;
2379 } 2380 }
2380 }; 2381 };
2381 2382
2382 } // namespace 2383 } // namespace
2383 2384
2385 ScriptPromise Internals::createPromise(ExecutionContext* context)
2386 {
2387 return ScriptPromiseResolver::create(context)->promise();
2388 }
2389
2390 ScriptPromise Internals::createResolvedPromise(ExecutionContext* context, Script Value value)
2391 {
2392 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(conte xt);
2393 ScriptPromise promise = resolver->promise();
2394 resolver->resolve(value);
2395 return promise;
2396 }
2397
2398 ScriptPromise Internals::createRejectedPromise(ExecutionContext* context, Script Value value)
2399 {
2400 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(conte xt);
2401 ScriptPromise promise = resolver->promise();
2402 resolver->reject(value);
2403 return promise;
2404 }
2405
2384 ScriptPromise Internals::addOneToPromise(ExecutionContext* context, ScriptPromis e promise) 2406 ScriptPromise Internals::addOneToPromise(ExecutionContext* context, ScriptPromis e promise)
2385 { 2407 {
2386 return promise.then(AddOneFunction::create(context)); 2408 return promise.then(AddOneFunction::create(context));
2387 } 2409 }
2388 2410
2389 void Internals::trace(Visitor* visitor) 2411 void Internals::trace(Visitor* visitor)
2390 { 2412 {
2391 visitor->trace(m_runtimeFlags); 2413 visitor->trace(m_runtimeFlags);
2392 visitor->trace(m_profilers); 2414 visitor->trace(m_profilers);
2393 } 2415 }
(...skipping 17 matching lines...) Expand all
2411 } 2433 }
2412 2434
2413 String Internals::textSurroundingNode(Node* node, int x, int y, unsigned long ma xLength) 2435 String Internals::textSurroundingNode(Node* node, int x, int y, unsigned long ma xLength)
2414 { 2436 {
2415 blink::WebPoint point(x, y); 2437 blink::WebPoint point(x, y);
2416 SurroundingText surroundingText(VisiblePosition(node->renderer()->positionFo rPoint(static_cast<IntPoint>(point))), maxLength); 2438 SurroundingText surroundingText(VisiblePosition(node->renderer()->positionFo rPoint(static_cast<IntPoint>(point))), maxLength);
2417 return surroundingText.content(); 2439 return surroundingText.content();
2418 } 2440 }
2419 2441
2420 } 2442 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698