diff options
3 files changed, 48 insertions, 3 deletions
diff --git a/webkit/data/layout_tests/chrome/fast/dom/window-postmessage-null-expected.txt b/webkit/data/layout_tests/chrome/fast/dom/window-postmessage-null-expected.txt new file mode 100644 index 0000000..4f365b0 --- /dev/null +++ b/webkit/data/layout_tests/chrome/fast/dom/window-postmessage-null-expected.txt @@ -0,0 +1,7 @@ +ALERT: 1 +ALERT: 2 +ALERT: 3 +ALERT: 4 +ALERT: 5 +ALERT: 6 +ALERT: done diff --git a/webkit/data/layout_tests/chrome/fast/dom/window-postmessage-null.html b/webkit/data/layout_tests/chrome/fast/dom/window-postmessage-null.html new file mode 100644 index 0000000..5fe9914 --- /dev/null +++ b/webkit/data/layout_tests/chrome/fast/dom/window-postmessage-null.html @@ -0,0 +1,36 @@ +<html> + +<script> +if (window.layoutTestController) { + layoutTestController.dumpAsText(); + layoutTestController.waitUntilDone(); +} + +function onmessage(evt) { + alert(evt.data); + + if (evt.data == 'done' && window.layoutTestController) + layoutTestController.notifyDone(); +} + +function run_test() { + window.addEventListener('message', onmessage); + try { + window.postMessage('1', 1, '*') + window.postMessage('2', "", '*') + window.postMessage('3', window, '*') + window.postMessage('4', { x: 1 }, '*') + window.postMessage('5', null, '*') + window.postMessage('6', void 0, '*') + window.postMessage('done', '*') + } catch(e) { + alert(e); + if (window.layoutTestController) + layoutTestController.notifyDone(); + } +} + +</script> +<body onload='run_test()'> +</body> +</html> diff --git a/webkit/port/bindings/v8/v8_custom.cpp b/webkit/port/bindings/v8/v8_custom.cpp index 8c505ad..1d807c3 100644 --- a/webkit/port/bindings/v8/v8_custom.cpp +++ b/webkit/port/bindings/v8/v8_custom.cpp @@ -295,7 +295,7 @@ CALLBACK_FUNC_DECL(MessageChannelConstructor) { V8Proxy::SetDOMWrapper( wrapper_object, V8ClassIndex::MESSAGECHANNEL, obj.get()); V8Proxy::SetJSWrapperForDOMObject( - obj.get(), v8::Persistent<v8::Object>::New(wrapper_object)); + obj.get(), v8::Persistent<v8::Object>::New(wrapper_object)); // Create references from the MessageChannel wrapper to the two // MessagePort wrappers to make sure that the MessagePort wrappers @@ -915,8 +915,10 @@ CALLBACK_FUNC_DECL(DOMWindowPostMessage) { // or // postMessage(message, domain); if (args.Length() > 2) { - port = V8Proxy::ToNativeObject<MessagePort>( - V8ClassIndex::MESSAGEPORT, args[1]); + if (V8Proxy::IsWrapperOfType(args[1], V8ClassIndex::MESSAGEPORT)) { + port = V8Proxy::ToNativeObject<MessagePort>( + V8ClassIndex::MESSAGEPORT, args[1]); + } domain = valueToStringWithNullOrUndefinedCheck(args[2]); } else { domain = valueToStringWithNullOrUndefinedCheck(args[1]); |