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

Side by Side Diff: Source/bindings/v8/custom/V8WindowCustom.cpp

Issue 30673002: More informative error messages for non-Transferables. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: More informative error messages for non-Transferables. Created 7 years, 1 month 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) 2009, 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "V8Window.h" 32 #include "V8Window.h"
33 33
34 #include "V8HTMLCollection.h" 34 #include "V8HTMLCollection.h"
35 #include "V8Node.h" 35 #include "V8Node.h"
36 #include "bindings/v8/BindingSecurity.h" 36 #include "bindings/v8/BindingSecurity.h"
37 #include "bindings/v8/ExceptionMessages.h"
37 #include "bindings/v8/ExceptionState.h" 38 #include "bindings/v8/ExceptionState.h"
38 #include "bindings/v8/ScheduledAction.h" 39 #include "bindings/v8/ScheduledAction.h"
39 #include "bindings/v8/ScriptController.h" 40 #include "bindings/v8/ScriptController.h"
40 #include "bindings/v8/ScriptSourceCode.h" 41 #include "bindings/v8/ScriptSourceCode.h"
41 #include "bindings/v8/SerializedScriptValue.h" 42 #include "bindings/v8/SerializedScriptValue.h"
42 #include "bindings/v8/V8Binding.h" 43 #include "bindings/v8/V8Binding.h"
43 #include "bindings/v8/V8EventListener.h" 44 #include "bindings/v8/V8EventListener.h"
44 #include "bindings/v8/V8EventListenerList.h" 45 #include "bindings/v8/V8EventListenerList.h"
45 #include "bindings/v8/V8GCForContextDispose.h" 46 #include "bindings/v8/V8GCForContextDispose.h"
46 #include "bindings/v8/V8HiddenPropertyName.h" 47 #include "bindings/v8/V8HiddenPropertyName.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // postMessage(message, {sequence of transferrables}, targetOrigin); 256 // postMessage(message, {sequence of transferrables}, targetOrigin);
256 MessagePortArray portArray; 257 MessagePortArray portArray;
257 ArrayBufferArray arrayBufferArray; 258 ArrayBufferArray arrayBufferArray;
258 int targetOriginArgIndex = 1; 259 int targetOriginArgIndex = 1;
259 if (args.Length() > 2) { 260 if (args.Length() > 2) {
260 int transferablesArgIndex = 2; 261 int transferablesArgIndex = 2;
261 if (isLegacyTargetOriginDesignation(args[2])) { 262 if (isLegacyTargetOriginDesignation(args[2])) {
262 targetOriginArgIndex = 2; 263 targetOriginArgIndex = 2;
263 transferablesArgIndex = 1; 264 transferablesArgIndex = 1;
264 } 265 }
265 if (!extractTransferables(args[transferablesArgIndex], portArray, arrayB ufferArray, args.GetIsolate())) 266 bool notASequence = false;
267 if (!extractTransferables(args[transferablesArgIndex], portArray, arrayB ufferArray, notASequence, args.GetIsolate())) {
268 if (notASequence)
269 throwTypeError(ExceptionMessages::failedToExecute("postMessage", "Window", ExceptionMessages::notASequenceType(transferablesArgIndex == 1 ? "Sec ond" : "Third")), args.GetIsolate());
266 return; 270 return;
271 }
267 } 272 }
268 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe ck>, targetOrigin, args[targetOriginArgIndex]); 273 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe ck>, targetOrigin, args[targetOriginArgIndex]);
269 274
270 bool didThrow = false; 275 bool didThrow = false;
271 RefPtr<SerializedScriptValue> message = 276 RefPtr<SerializedScriptValue> message =
272 SerializedScriptValue::create(args[0], &portArray, &arrayBufferArray, di dThrow, args.GetIsolate()); 277 SerializedScriptValue::create(args[0], &portArray, &arrayBufferArray, di dThrow, args.GetIsolate());
273 if (didThrow) 278 if (didThrow)
274 return; 279 return;
275 280
276 ExceptionState es(args.GetIsolate()); 281 ExceptionState es(args.GetIsolate());
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 v8::Handle<v8::Context> context = frame->script()->currentWorldContext(); 543 v8::Handle<v8::Context> context = frame->script()->currentWorldContext();
539 if (context.IsEmpty()) 544 if (context.IsEmpty())
540 return v8Undefined(); 545 return v8Undefined();
541 546
542 v8::Handle<v8::Object> global = context->Global(); 547 v8::Handle<v8::Object> global = context->Global();
543 ASSERT(!global.IsEmpty()); 548 ASSERT(!global.IsEmpty());
544 return global; 549 return global;
545 } 550 }
546 551
547 } // namespace WebCore 552 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/custom/V8MessagePortCustom.cpp ('k') | Source/bindings/v8/custom/V8WorkerCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698