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

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

Issue 2817533003: Replace ASSERT, RELEASE_ASSERT, and ASSERT_NOT_REACHED in bindings (Closed)
Patch Set: fixed dcheck build error Created 3 years, 8 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) 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 BindingSecurity::ErrorReportOption::kDoNotReport)) { 155 BindingSecurity::ErrorReportOption::kDoNotReport)) {
156 V8SetReturnValueNull(info); 156 V8SetReturnValueNull(info);
157 return; 157 return;
158 } 158 }
159 159
160 // The wrapper for an <iframe> should get its prototype from the context of 160 // The wrapper for an <iframe> should get its prototype from the context of
161 // the frame it's in, rather than its own frame. 161 // the frame it's in, rather than its own frame.
162 // So, use its containing document as the creation context when wrapping. 162 // So, use its containing document as the creation context when wrapping.
163 v8::Local<v8::Value> creation_context = ToV8( 163 v8::Local<v8::Value> creation_context = ToV8(
164 &impl->frameElement()->GetDocument(), info.Holder(), info.GetIsolate()); 164 &impl->frameElement()->GetDocument(), info.Holder(), info.GetIsolate());
165 RELEASE_ASSERT(!creation_context.IsEmpty()); 165 CHECK(!creation_context.IsEmpty());
166 v8::Local<v8::Value> wrapper = 166 v8::Local<v8::Value> wrapper =
167 ToV8(impl->frameElement(), v8::Local<v8::Object>::Cast(creation_context), 167 ToV8(impl->frameElement(), v8::Local<v8::Object>::Cast(creation_context),
168 info.GetIsolate()); 168 info.GetIsolate());
169 V8SetReturnValue(info, wrapper); 169 V8SetReturnValue(info, wrapper);
170 } 170 }
171 171
172 void V8Window::openerAttributeSetterCustom( 172 void V8Window::openerAttributeSetterCustom(
173 v8::Local<v8::Value> value, 173 v8::Local<v8::Value> value,
174 const v8::PropertyCallbackInfo<void>& info) { 174 const v8::PropertyCallbackInfo<void>& info) {
175 v8::Isolate* isolate = info.GetIsolate(); 175 v8::Isolate* isolate = info.GetIsolate();
176 DOMWindow* impl = V8Window::toImpl(info.Holder()); 176 DOMWindow* impl = V8Window::toImpl(info.Holder());
177 // TODO(dcheng): Investigate removing this, since opener is not really a 177 // TODO(dcheng): Investigate removing this, since opener is not really a
178 // cross-origin property (so it shouldn't be accessible to begin with) 178 // cross-origin property (so it shouldn't be accessible to begin with)
179 ExceptionState exception_state(isolate, ExceptionState::kSetterContext, 179 ExceptionState exception_state(isolate, ExceptionState::kSetterContext,
180 "Window", "opener"); 180 "Window", "opener");
181 if (!BindingSecurity::ShouldAllowAccessTo(CurrentDOMWindow(info.GetIsolate()), 181 if (!BindingSecurity::ShouldAllowAccessTo(CurrentDOMWindow(info.GetIsolate()),
182 impl, exception_state)) { 182 impl, exception_state)) {
183 return; 183 return;
184 } 184 }
185 185
186 // Opener can be shadowed if it is in the same domain. 186 // Opener can be shadowed if it is in the same domain.
187 // Have a special handling of null value to behave 187 // Have a special handling of null value to behave
188 // like Firefox. See bug http://b/1224887 & http://b/791706. 188 // like Firefox. See bug http://b/1224887 & http://b/791706.
189 if (value->IsNull()) { 189 if (value->IsNull()) {
190 // impl->frame() has to be a non-null LocalFrame. Otherwise, the 190 // impl->frame() has to be a non-null LocalFrame. Otherwise, the
191 // same-origin check would have failed. 191 // same-origin check would have failed.
192 ASSERT(impl->GetFrame()); 192 DCHECK(impl->GetFrame());
193 ToLocalFrame(impl->GetFrame())->Loader().SetOpener(0); 193 ToLocalFrame(impl->GetFrame())->Loader().SetOpener(0);
194 } 194 }
195 195
196 // Delete the accessor from the inner object. 196 // Delete the accessor from the inner object.
197 if (info.Holder() 197 if (info.Holder()
198 ->Delete(isolate->GetCurrentContext(), 198 ->Delete(isolate->GetCurrentContext(),
199 V8AtomicString(isolate, "opener")) 199 V8AtomicString(isolate, "opener"))
200 .IsNothing()) { 200 .IsNothing()) {
201 return; 201 return;
202 } 202 }
(...skipping 21 matching lines...) Expand all
224 224
225 // None of these need to be RefPtr because info and context are guaranteed 225 // None of these need to be RefPtr because info and context are guaranteed
226 // to hold on to them. 226 // to hold on to them.
227 DOMWindow* window = V8Window::toImpl(info.Holder()); 227 DOMWindow* window = V8Window::toImpl(info.Holder());
228 // TODO(yukishiino): The HTML spec specifies that we should use the 228 // TODO(yukishiino): The HTML spec specifies that we should use the
229 // Incumbent Realm instead of the Current Realm, but currently we don't have 229 // Incumbent Realm instead of the Current Realm, but currently we don't have
230 // a way to retrieve the Incumbent Realm. See also: 230 // a way to retrieve the Incumbent Realm. See also:
231 // https://html.spec.whatwg.org/multipage/comms.html#dom-window-postmessage 231 // https://html.spec.whatwg.org/multipage/comms.html#dom-window-postmessage
232 LocalDOMWindow* source = CurrentDOMWindow(info.GetIsolate()); 232 LocalDOMWindow* source = CurrentDOMWindow(info.GetIsolate());
233 233
234 ASSERT(window); 234 DCHECK(window);
235 UseCounter::Count(window->GetFrame(), UseCounter::kWindowPostMessage); 235 UseCounter::Count(window->GetFrame(), UseCounter::kWindowPostMessage);
236 236
237 // If called directly by WebCore we don't have a calling context. 237 // If called directly by WebCore we don't have a calling context.
238 if (!source) { 238 if (!source) {
239 exception_state.ThrowTypeError("No active calling context exists."); 239 exception_state.ThrowTypeError("No active calling context exists.");
240 return; 240 return;
241 } 241 }
242 242
243 // This function has variable arguments and can be: 243 // This function has variable arguments and can be:
244 // postMessage(message, targetOrigin) 244 // postMessage(message, targetOrigin)
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 if (items->HasExactlyOneItem()) { 392 if (items->HasExactlyOneItem()) {
393 V8SetReturnValueFast(info, items->item(0), window); 393 V8SetReturnValueFast(info, items->item(0), window);
394 return; 394 return;
395 } 395 }
396 V8SetReturnValueFast(info, items, window); 396 V8SetReturnValueFast(info, items, window);
397 return; 397 return;
398 } 398 }
399 } 399 }
400 400
401 } // namespace blink 401 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698