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

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

Issue 232563003: API functions returning Promises should not throw exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
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 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after
2264 } 2264 }
2265 2265
2266 ScriptPromise Internals::createRejectedPromise(ScriptState* scriptState, ScriptV alue value) 2266 ScriptPromise Internals::createRejectedPromise(ScriptState* scriptState, ScriptV alue value)
2267 { 2267 {
2268 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); 2268 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState);
2269 ScriptPromise promise = resolver->promise(); 2269 ScriptPromise promise = resolver->promise();
2270 resolver->reject(value); 2270 resolver->reject(value);
2271 return promise; 2271 return promise;
2272 } 2272 }
2273 2273
2274 ScriptPromise Internals::addOneToPromise(ExecutionContext* context, ScriptPromis e promise) 2274 ScriptPromise Internals::addOneToPromise(ScriptState* scriptState, ScriptPromise promise)
2275 { 2275 {
2276 return promise.then(AddOneFunction::create(context)); 2276 return promise.then(AddOneFunction::create(scriptState->executionContext())) ;
2277 }
2278
2279 ScriptPromise Internals::promiseCheck(ScriptState* scriptState, long arg1, bool arg2, const Dictionary& arg3, const String& arg4, const Vector<String>& arg5, Ex ceptionState& exceptionState)
2280 {
2281 if (arg2)
2282 return ScriptPromise::cast(scriptState, v8String(scriptState->isolate(), "done"));
2283 exceptionState.throwDOMException(InvalidStateError, "Thrown from the native implementation.");
2284 return ScriptPromise();
2285 }
2286
2287 ScriptPromise Internals::promiseCheckWithoutExceptionState(ScriptState* scriptSt ate, const Dictionary& arg1, const String& arg2, const Vector<String>& arg3)
2288 {
2289 return ScriptPromise::cast(scriptState, v8String(scriptState->isolate(), "do ne"));
2290 }
2291
2292 ScriptPromise Internals::promiseCheckRange(ScriptState* scriptState, long arg1)
2293 {
2294 return ScriptPromise::cast(scriptState, v8String(scriptState->isolate(), "do ne"));
2277 } 2295 }
2278 2296
2279 void Internals::trace(Visitor* visitor) 2297 void Internals::trace(Visitor* visitor)
2280 { 2298 {
2281 visitor->trace(m_runtimeFlags); 2299 visitor->trace(m_runtimeFlags);
2282 visitor->trace(m_profilers); 2300 visitor->trace(m_profilers);
2283 } 2301 }
2284 2302
2285 void Internals::setValueForUser(Element* element, const String& value) 2303 void Internals::setValueForUser(Element* element, const String& value)
2286 { 2304 {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2352 2370
2353 StringBuilder markup; 2371 StringBuilder markup;
2354 Vector<Document::TransitionElementData>::iterator iter = elementData.begin() ; 2372 Vector<Document::TransitionElementData>::iterator iter = elementData.begin() ;
2355 for (; iter != elementData.end(); ++iter) 2373 for (; iter != elementData.end(); ++iter)
2356 markup.append(iter->markup); 2374 markup.append(iter->markup);
2357 2375
2358 return markup.toString(); 2376 return markup.toString();
2359 } 2377 }
2360 2378
2361 } // namespace blink 2379 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698