Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index 3c6f85ed72a0cc95f77754a3f850b2727c381b43..92ab5b8546959c820af1cd46ddfd485e80e0a83a 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -3565,6 +3565,7 @@ static void check_message_0(v8::Handle<v8::Message> message, |
CHECK_EQ(5.76, data->NumberValue()); |
CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); |
CHECK_EQ(7.56, message->GetScriptData()->NumberValue()); |
+ CHECK(!message->IsSharedCrossOrigin()); |
message_received = true; |
} |
@@ -3591,6 +3592,7 @@ static void check_message_1(v8::Handle<v8::Message> message, |
v8::Handle<Value> data) { |
CHECK(data->IsNumber()); |
CHECK_EQ(1337, data->Int32Value()); |
+ CHECK(!message->IsSharedCrossOrigin()); |
message_received = true; |
} |
@@ -3615,6 +3617,7 @@ static void check_message_2(v8::Handle<v8::Message> message, |
v8::Local<v8::Value> hidden_property = |
v8::Object::Cast(*data)->GetHiddenValue(v8_str("hidden key")); |
CHECK(v8_str("hidden value")->Equals(hidden_property)); |
+ CHECK(!message->IsSharedCrossOrigin()); |
message_received = true; |
} |
@@ -3636,6 +3639,112 @@ TEST(MessageHandler2) { |
} |
+static void check_message_3(v8::Handle<v8::Message> message, |
+ v8::Handle<Value> data) { |
+ CHECK(message->IsSharedCrossOrigin()); |
+ CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); |
+ message_received = true; |
+} |
+ |
+ |
+TEST(MessageHandler3) { |
+ message_received = false; |
+ v8::HandleScope scope(v8::Isolate::GetCurrent()); |
+ CHECK(!message_received); |
+ v8::V8::AddMessageListener(check_message_3); |
+ LocalContext context; |
+ v8::ScriptOrigin origin = |
+ v8::ScriptOrigin(v8_str("6.75"), |
+ v8::Integer::New(1), |
+ v8::Integer::New(2), |
+ v8::True()); |
+ v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
+ &origin); |
+ script->Run(); |
+ CHECK(message_received); |
+ // clear out the message listener |
+ v8::V8::RemoveMessageListeners(check_message_3); |
+} |
+ |
+ |
+static void check_message_4(v8::Handle<v8::Message> message, |
+ v8::Handle<Value> data) { |
+ CHECK(!message->IsSharedCrossOrigin()); |
+ CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); |
+ message_received = true; |
+} |
+ |
+ |
+TEST(MessageHandler4) { |
+ message_received = false; |
+ v8::HandleScope scope(v8::Isolate::GetCurrent()); |
+ CHECK(!message_received); |
+ v8::V8::AddMessageListener(check_message_4); |
+ LocalContext context; |
+ v8::ScriptOrigin origin = |
+ v8::ScriptOrigin(v8_str("6.75"), |
+ v8::Integer::New(1), |
+ v8::Integer::New(2), |
+ v8::False()); |
+ v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
+ &origin); |
+ script->Run(); |
+ CHECK(message_received); |
+ // clear out the message listener |
+ v8::V8::RemoveMessageListeners(check_message_4); |
+} |
+ |
+ |
+static void check_message_5a(v8::Handle<v8::Message> message, |
+ v8::Handle<Value> data) { |
+ CHECK(message->IsSharedCrossOrigin()); |
+ CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); |
+ message_received = true; |
+} |
+ |
+ |
+static void check_message_5b(v8::Handle<v8::Message> message, |
+ v8::Handle<Value> data) { |
+ CHECK(!message->IsSharedCrossOrigin()); |
+ CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); |
+ message_received = true; |
+} |
+ |
+ |
+TEST(MessageHandler5) { |
+ message_received = false; |
+ v8::HandleScope scope(v8::Isolate::GetCurrent()); |
+ CHECK(!message_received); |
+ v8::V8::AddMessageListener(check_message_5a); |
+ LocalContext context; |
+ v8::ScriptOrigin origin = |
+ v8::ScriptOrigin(v8_str("6.75"), |
+ v8::Integer::New(1), |
+ v8::Integer::New(2), |
+ v8::True()); |
+ v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
+ &origin); |
+ script->Run(); |
+ CHECK(message_received); |
+ // clear out the message listener |
+ v8::V8::RemoveMessageListeners(check_message_5a); |
+ |
+ message_received = false; |
+ v8::V8::AddMessageListener(check_message_5b); |
+ origin = |
+ v8::ScriptOrigin(v8_str("6.75"), |
+ v8::Integer::New(1), |
+ v8::Integer::New(2), |
+ v8::False()); |
+ script = Script::Compile(v8_str("throw 'error'"), |
+ &origin); |
+ script->Run(); |
+ CHECK(message_received); |
+ // clear out the message listener |
+ v8::V8::RemoveMessageListeners(check_message_5b); |
+} |
+ |
+ |
THREADED_TEST(GetSetProperty) { |
LocalContext context; |
v8::HandleScope scope(context->GetIsolate()); |