| OLD | NEW |
| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 static bool isLegacyTargetOriginDesignation(v8::Handle<v8::Value> value) | 152 static bool isLegacyTargetOriginDesignation(v8::Handle<v8::Value> value) |
| 153 { | 153 { |
| 154 if (value->IsString() || value->IsStringObject()) | 154 if (value->IsString() || value->IsStringObject()) |
| 155 return true; | 155 return true; |
| 156 return false; | 156 return false; |
| 157 } | 157 } |
| 158 | 158 |
| 159 | 159 |
| 160 void V8Window::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>
& info) | 160 void V8Window::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>
& info) |
| 161 { | 161 { |
| 162 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage
", "Window", info.Holder(), info.GetIsolate()); | |
| 163 if (UNLIKELY(info.Length() < 2)) { | |
| 164 setMinimumArityTypeError(exceptionState, 2, info.Length()); | |
| 165 exceptionState.throwIfNeeded(); | |
| 166 return; | |
| 167 } | |
| 168 | |
| 169 // None of these need to be RefPtr because info and context are guaranteed | 162 // None of these need to be RefPtr because info and context are guaranteed |
| 170 // to hold on to them. | 163 // to hold on to them. |
| 171 DOMWindow* window = V8Window::toImpl(info.Holder()); | 164 DOMWindow* window = V8Window::toImpl(info.Holder()); |
| 172 LocalDOMWindow* source = callingDOMWindow(info.GetIsolate()); | 165 LocalDOMWindow* source = callingDOMWindow(info.GetIsolate()); |
| 173 | 166 |
| 174 ASSERT(window); | 167 ASSERT(window); |
| 175 UseCounter::countIfNotPrivateScript(info.GetIsolate(), window->frame(), UseC
ounter::WindowPostMessage); | 168 UseCounter::countIfNotPrivateScript(info.GetIsolate(), window->frame(), UseC
ounter::WindowPostMessage); |
| 176 | 169 |
| 170 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage
", "Window", info.Holder(), info.GetIsolate()); |
| 171 |
| 177 // If called directly by WebCore we don't have a calling context. | 172 // If called directly by WebCore we don't have a calling context. |
| 178 if (!source) { | 173 if (!source) { |
| 179 exceptionState.throwTypeError("No active calling context exists."); | 174 exceptionState.throwTypeError("No active calling context exists."); |
| 180 exceptionState.throwIfNeeded(); | 175 exceptionState.throwIfNeeded(); |
| 181 return; | 176 return; |
| 182 } | 177 } |
| 183 | 178 |
| 184 // This function has variable arguments and can be: | 179 // This function has variable arguments and can be: |
| 185 // Per current spec: | 180 // Per current spec: |
| 186 // postMessage(message, targetOrigin) | 181 // postMessage(message, targetOrigin) |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 v8::Handle<v8::Context> context = toV8Context(frame, DOMWrapperWorld::curren
t(isolate)); | 355 v8::Handle<v8::Context> context = toV8Context(frame, DOMWrapperWorld::curren
t(isolate)); |
| 361 if (context.IsEmpty()) | 356 if (context.IsEmpty()) |
| 362 return v8Undefined(); | 357 return v8Undefined(); |
| 363 | 358 |
| 364 v8::Handle<v8::Object> global = context->Global(); | 359 v8::Handle<v8::Object> global = context->Global(); |
| 365 ASSERT(!global.IsEmpty()); | 360 ASSERT(!global.IsEmpty()); |
| 366 return global; | 361 return global; |
| 367 } | 362 } |
| 368 | 363 |
| 369 } // namespace blink | 364 } // namespace blink |
| OLD | NEW |