| Index: third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp
|
| index 245e99622626568027ba607f3571a8a8ca108f30..d7c0f26d43f625e1156c65fc56020f0ab9cebb26 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp
|
| @@ -153,6 +153,14 @@ void V8Window::openerAttributeSetterCustom(v8::Local<v8::Value> value, const v8:
|
| }
|
| }
|
|
|
| +static bool isLegacyTargetOriginDesignation(v8::Local<v8::Value> value)
|
| +{
|
| + if (value->IsString() || value->IsStringObject())
|
| + return true;
|
| + return false;
|
| +}
|
| +
|
| +
|
| void V8Window::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage", "Window", info.Holder(), info.GetIsolate());
|
| @@ -182,22 +190,25 @@ void V8Window::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>
|
| }
|
|
|
| // This function has variable arguments and can be:
|
| + // Per current spec:
|
| // postMessage(message, targetOrigin)
|
| // postMessage(message, targetOrigin, {sequence of transferrables})
|
| - // TODO(foolip): Type checking of the arguments should happen in order, so
|
| - // that e.g. postMessage({}, { toString: () => { throw Error(); } }, 0)
|
| - // throws the Error from toString, not the TypeError for argument 3.
|
| + // Legacy non-standard implementations in webkit allowed:
|
| + // postMessage(message, {sequence of transferrables}, targetOrigin);
|
| Transferables transferables;
|
| - const int targetOriginArgIndex = 1;
|
| + int targetOriginArgIndex = 1;
|
| if (info.Length() > 2) {
|
| - const int transferablesArgIndex = 2;
|
| + int transferablesArgIndex = 2;
|
| + if (isLegacyTargetOriginDesignation(info[2])) {
|
| + Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), window->document(), UseCounter::WindowPostMessageWithLegacyTargetOriginArgument);
|
| + targetOriginArgIndex = 2;
|
| + transferablesArgIndex = 1;
|
| + }
|
| if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info[transferablesArgIndex], transferablesArgIndex, transferables, exceptionState)) {
|
| exceptionState.throwIfNeeded();
|
| return;
|
| }
|
| }
|
| - // TODO(foolip): targetOrigin should be a USVString in IDL and treated as
|
| - // such here, without TreatNullAndUndefinedAsNullString.
|
| TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, targetOrigin, info[targetOriginArgIndex]);
|
|
|
| RefPtr<SerializedScriptValue> message = SerializedScriptValue::serialize(info.GetIsolate(), info[0], &transferables, nullptr, exceptionState);
|
|
|