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

Side by Side Diff: Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp

Issue 8041034: Merge 95689 - [Chromium] Protect message ports from being deleted in V8MessageEvent::portsAccesso... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/835/
Patch Set: Created 9 years, 2 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/dom/message-port-deleted-by-accessor-expected.txt ('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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 namespace WebCore { 43 namespace WebCore {
44 44
45 v8::Handle<v8::Value> V8MessageEvent::portsAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) 45 v8::Handle<v8::Value> V8MessageEvent::portsAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
46 { 46 {
47 INC_STATS("DOM.MessageEvent.ports"); 47 INC_STATS("DOM.MessageEvent.ports");
48 MessageEvent* event = V8MessageEvent::toNative(info.Holder()); 48 MessageEvent* event = V8MessageEvent::toNative(info.Holder());
49 49
50 MessagePortArray* ports = event->ports(); 50 MessagePortArray* ports = event->ports();
51 if (!ports || ports->isEmpty()) 51 if (!ports || ports->isEmpty())
52 return v8::Null(); 52 return v8::Null();
53
54 MessagePortArray portsCopy(*ports);
53 55
54 v8::Local<v8::Array> portArray = v8::Array::New(ports->size()); 56 v8::Local<v8::Array> portArray = v8::Array::New(portsCopy.size());
55 for (size_t i = 0; i < ports->size(); ++i) 57 for (size_t i = 0; i < portsCopy.size(); ++i)
56 portArray->Set(v8::Integer::New(i), toV8((*ports)[i].get())); 58 portArray->Set(v8::Integer::New(i), toV8(portsCopy[i].get()));
57 59
58 return portArray; 60 return portArray;
59 } 61 }
60 62
61 v8::Handle<v8::Value> V8MessageEvent::initMessageEventCallback(const v8::Argumen ts& args) 63 v8::Handle<v8::Value> V8MessageEvent::initMessageEventCallback(const v8::Argumen ts& args)
62 { 64 {
63 INC_STATS("DOM.MessageEvent.initMessageEvent"); 65 INC_STATS("DOM.MessageEvent.initMessageEvent");
64 MessageEvent* event = V8MessageEvent::toNative(args.Holder()); 66 MessageEvent* event = V8MessageEvent::toNative(args.Holder());
65 String typeArg = v8ValueToWebCoreString(args[0]); 67 String typeArg = v8ValueToWebCoreString(args[0]);
66 bool canBubbleArg = args[1]->BooleanValue(); 68 bool canBubbleArg = args[1]->BooleanValue();
(...skipping 16 matching lines...) Expand all
83 if (!getMessagePortArray(args[7], *portArray)) 85 if (!getMessagePortArray(args[7], *portArray))
84 return v8::Undefined(); 86 return v8::Undefined();
85 } 87 }
86 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg.releas e(), originArg, lastEventIdArg, sourceArg, portArray.release()); 88 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg.releas e(), originArg, lastEventIdArg, sourceArg, portArray.release());
87 v8::PropertyAttribute dataAttr = static_cast<v8::PropertyAttribute>(v8::Dont Delete | v8::ReadOnly); 89 v8::PropertyAttribute dataAttr = static_cast<v8::PropertyAttribute>(v8::Dont Delete | v8::ReadOnly);
88 SerializedScriptValue::deserializeAndSetProperty(args.Holder(), "data", data Attr, event->data()); 90 SerializedScriptValue::deserializeAndSetProperty(args.Holder(), "data", data Attr, event->data());
89 return v8::Undefined(); 91 return v8::Undefined();
90 } 92 }
91 93
92 } // namespace WebCore 94 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/message-port-deleted-by-accessor-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698