зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1046880 - Test for NativeJSObject exceptions; r=rnewman
This commit is contained in:
Родитель
2c9c0f8dad
Коммит
a359b31554
|
@ -29,6 +29,7 @@ public class testEventDispatcher extends UITest
|
|||
private static final String GECKO_RESPONSE_EVENT = "Robocop:TestGeckoResponse";
|
||||
private static final String NATIVE_EVENT = "Robocop:TestNativeEvent";
|
||||
private static final String NATIVE_RESPONSE_EVENT = "Robocop:TestNativeResponse";
|
||||
private static final String NATIVE_EXCEPTION_EVENT = "Robocop:TestNativeException";
|
||||
|
||||
private JavascriptBridge js;
|
||||
|
||||
|
@ -40,7 +41,8 @@ public class testEventDispatcher extends UITest
|
|||
EventDispatcher.getInstance().registerGeckoThreadListener(
|
||||
(GeckoEventListener) this, GECKO_EVENT, GECKO_RESPONSE_EVENT);
|
||||
EventDispatcher.getInstance().registerGeckoThreadListener(
|
||||
(NativeEventListener) this, NATIVE_EVENT, NATIVE_RESPONSE_EVENT);
|
||||
(NativeEventListener) this,
|
||||
NATIVE_EVENT, NATIVE_RESPONSE_EVENT, NATIVE_EXCEPTION_EVENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,7 +50,8 @@ public class testEventDispatcher extends UITest
|
|||
EventDispatcher.getInstance().unregisterGeckoThreadListener(
|
||||
(GeckoEventListener) this, GECKO_EVENT, GECKO_RESPONSE_EVENT);
|
||||
EventDispatcher.getInstance().unregisterGeckoThreadListener(
|
||||
(NativeEventListener) this, NATIVE_EVENT, NATIVE_RESPONSE_EVENT);
|
||||
(NativeEventListener) this,
|
||||
NATIVE_EVENT, NATIVE_RESPONSE_EVENT, NATIVE_EXCEPTION_EVENT);
|
||||
|
||||
js.disconnect();
|
||||
super.tearDown();
|
||||
|
@ -66,6 +69,7 @@ public class testEventDispatcher extends UITest
|
|||
js.syncCall("send_message_for_response", NATIVE_RESPONSE_EVENT, "success");
|
||||
js.syncCall("send_message_for_response", NATIVE_RESPONSE_EVENT, "error");
|
||||
js.syncCall("send_message_for_response", NATIVE_RESPONSE_EVENT, "cancel");
|
||||
js.syncCall("send_test_message", NATIVE_EXCEPTION_EVENT);
|
||||
js.syncCall("finish_test");
|
||||
}
|
||||
|
||||
|
@ -151,6 +155,30 @@ public class testEventDispatcher extends UITest
|
|||
fFail("Response type should be valid: " + response);
|
||||
}
|
||||
|
||||
} else if (NATIVE_EXCEPTION_EVENT.equals(event)) {
|
||||
// Make sure we throw the right exceptions.
|
||||
try {
|
||||
message.getString(null);
|
||||
fFail("null property name should throw IllegalArgumentException");
|
||||
} catch (final IllegalArgumentException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
message.getString("nonexistent_string");
|
||||
fFail("Nonexistent property name should throw InvalidPropertyException");
|
||||
} catch (final NativeJSObject.InvalidPropertyException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
message.getString("int");
|
||||
fFail("Wrong property type should throw InvalidPropertyException");
|
||||
} catch (final NativeJSObject.InvalidPropertyException e) {
|
||||
}
|
||||
|
||||
// Save this test for last; make sure EventDispatcher catches InvalidPropertyException.
|
||||
message.getString("nonexistent_string");
|
||||
fFail("EventDispatcher should catch InvalidPropertyException");
|
||||
|
||||
} else {
|
||||
fFail("Event type should be valid: " + event);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче