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

Side by Side Diff: Source/bindings/v8/V8Utilities.cpp

Issue 138273013: Check for duplicate ArrayBuffer transferables. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update test to current Created 6 years, 11 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 | « LayoutTests/fast/events/resources/message-port-multi.js ('k') | no next file » | 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) 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 2009 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 // Validation of Objects implementing an interface, per WebIDL spec 4.1. 15. 94 // Validation of Objects implementing an interface, per WebIDL spec 4.1. 15.
95 if (V8MessagePort::hasInstance(transferrable, isolate, worldType(isolate ))) { 95 if (V8MessagePort::hasInstance(transferrable, isolate, worldType(isolate ))) {
96 RefPtr<MessagePort> port = V8MessagePort::toNative(v8::Handle<v8::Ob ject>::Cast(transferrable)); 96 RefPtr<MessagePort> port = V8MessagePort::toNative(v8::Handle<v8::Ob ject>::Cast(transferrable));
97 // Check for duplicate MessagePorts. 97 // Check for duplicate MessagePorts.
98 if (ports.contains(port)) { 98 if (ports.contains(port)) {
99 exceptionState.throwDOMException(DataCloneError, "Message port a t index " + String::number(i) + " is a duplicate of an earlier port."); 99 exceptionState.throwDOMException(DataCloneError, "Message port a t index " + String::number(i) + " is a duplicate of an earlier port.");
100 return false; 100 return false;
101 } 101 }
102 ports.append(port.release()); 102 ports.append(port.release());
103 } else if (V8ArrayBuffer::hasInstance(transferrable, isolate, worldType( isolate))) 103 } else if (V8ArrayBuffer::hasInstance(transferrable, isolate, worldType( isolate))) {
104 arrayBuffers.append(V8ArrayBuffer::toNative(v8::Handle<v8::Object>:: Cast(transferrable))); 104 RefPtr<ArrayBuffer> arrayBuffer = V8ArrayBuffer::toNative(v8::Handle <v8::Object>::Cast(transferrable));
105 else { 105 if (arrayBuffers.contains(arrayBuffer)) {
106 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at index " + String::number(i) + " is a duplicate of an earlier ArrayBuffer.");
107 return false;
108 }
109 arrayBuffers.append(arrayBuffer.release());
110 } else {
106 exceptionState.throwDOMException(DataCloneError, "Value at index " + String::number(i) + " does not have a transferable type."); 111 exceptionState.throwDOMException(DataCloneError, "Value at index " + String::number(i) + " does not have a transferable type.");
107 return false; 112 return false;
108 } 113 }
109 } 114 }
110 return true; 115 return true;
111 } 116 }
112 117
113 bool getMessagePortArray(v8::Local<v8::Value> value, const String& propertyName, MessagePortArray& ports, v8::Isolate* isolate) 118 bool getMessagePortArray(v8::Local<v8::Value> value, const String& propertyName, MessagePortArray& ports, v8::Isolate* isolate)
114 { 119 {
115 if (isUndefinedOrNull(value)) { 120 if (isUndefinedOrNull(value)) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 177
173 ExecutionContext* getExecutionContext() 178 ExecutionContext* getExecutionContext()
174 { 179 {
175 if (WorkerScriptController* controller = WorkerScriptController::controllerF orContext()) 180 if (WorkerScriptController* controller = WorkerScriptController::controllerF orContext())
176 return &controller->workerGlobalScope(); 181 return &controller->workerGlobalScope();
177 182
178 return currentDocument(); 183 return currentDocument();
179 } 184 }
180 185
181 } // namespace WebCore 186 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/events/resources/message-port-multi.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698