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

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

Issue 22470008: Implement ScriptPromise and ScriptFunction (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed expectation Created 7 years, 4 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 | Annotate | Revision Log
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 21 matching lines...) Expand all
32 #include "InternalProfilers.h" 32 #include "InternalProfilers.h"
33 #include "InternalRuntimeFlags.h" 33 #include "InternalRuntimeFlags.h"
34 #include "InternalSettings.h" 34 #include "InternalSettings.h"
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/ExceptionState.h" 41 #include "bindings/v8/ExceptionState.h"
42 #include "bindings/v8/ScriptFunction.h"
43 #include "bindings/v8/ScriptPromise.h"
42 #include "bindings/v8/SerializedScriptValue.h" 44 #include "bindings/v8/SerializedScriptValue.h"
43 #include "bindings/v8/V8ThrowException.h" 45 #include "bindings/v8/V8ThrowException.h"
44 #include "core/css/StyleSheetContents.h" 46 #include "core/css/StyleSheetContents.h"
45 #include "core/css/resolver/StyleResolver.h" 47 #include "core/css/resolver/StyleResolver.h"
46 #include "core/css/resolver/ViewportStyleResolver.h" 48 #include "core/css/resolver/ViewportStyleResolver.h"
47 #include "core/dom/ClientRect.h" 49 #include "core/dom/ClientRect.h"
48 #include "core/dom/ClientRectList.h" 50 #include "core/dom/ClientRectList.h"
49 #include "core/dom/DOMStringList.h" 51 #include "core/dom/DOMStringList.h"
50 #include "core/dom/Document.h" 52 #include "core/dom/Document.h"
51 #include "core/dom/DocumentMarker.h" 53 #include "core/dom/DocumentMarker.h"
(...skipping 2017 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 if (!sharedContext) 2071 if (!sharedContext)
2070 return false; 2072 return false;
2071 sharedContext->getExtensions()->loseContextCHROMIUM(Extensions3D::GUILTY_CON TEXT_RESET_ARB, Extensions3D::INNOCENT_CONTEXT_RESET_ARB); 2073 sharedContext->getExtensions()->loseContextCHROMIUM(Extensions3D::GUILTY_CON TEXT_RESET_ARB, Extensions3D::INNOCENT_CONTEXT_RESET_ARB);
2072 // To prevent tests that call loseSharedGraphicsContext3D from being 2074 // To prevent tests that call loseSharedGraphicsContext3D from being
2073 // flaky, we call finish so that the context is guaranteed to be lost 2075 // flaky, we call finish so that the context is guaranteed to be lost
2074 // synchronously (i.e. before returning). 2076 // synchronously (i.e. before returning).
2075 sharedContext->finish(); 2077 sharedContext->finish();
2076 return true; 2078 return true;
2077 } 2079 }
2078 2080
2081 class AddOneCallback : public ScriptFunction {
2082 public:
2083 virtual ScriptValue call(ScriptValue value) OVERRIDE
2084 {
2085 v8::Local<v8::Value> v8Value = value.v8Value();
2086 ASSERT(v8Value->IsNumber());
2087 int intValue = v8Value.As<v8::Integer>()->Value();
2088 ScriptValue result = ScriptValue(v8::Integer::New(intValue + 1));
2089 return result;
2090 }
2091 };
2092
2093 ScriptValue Internals::addOneToPromise(ScriptValue promiseValue)
2094 {
2095 ScriptPromise promise(promiseValue);
2096
2097 bool result = promise.then(adoptRef(new AddOneCallback()));
2098 ASSERT(result);
2099
2100 return promise.ResultPromise();
2079 } 2101 }
2102
2103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698