mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 995820 - Wait for JavaBridge to load before sending messages to it; r=mcomella
This commit is contained in:
parent
449e20f6ed
commit
2a7e0c40d6
@ -67,6 +67,8 @@ public final class JavascriptBridge {
|
||||
private JSONObject mSavedAsyncMessage;
|
||||
// Number of levels in the synchronous call stack
|
||||
private int mCallStackDepth;
|
||||
// If JavaBridge has been loaded
|
||||
private boolean mJavaBridgeLoaded;
|
||||
|
||||
/* package */ static void init(final UITestContext context) {
|
||||
sActions = context.getActions();
|
||||
@ -181,7 +183,15 @@ public final class JavascriptBridge {
|
||||
} while (result != MessageStatus.QUEUE_EMPTY);
|
||||
}
|
||||
|
||||
private void ensureJavaBridgeLoaded() {
|
||||
while (!mJavaBridgeLoaded) {
|
||||
processPendingMessage();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendMessage(final String innerType, final String method, final Object[] args) {
|
||||
ensureJavaBridgeLoaded();
|
||||
|
||||
// Call from Java to Javascript
|
||||
final JSONObject message = new JSONObject();
|
||||
final JSONArray jsonArgs = new JSONArray();
|
||||
@ -217,6 +227,10 @@ public final class JavascriptBridge {
|
||||
mLogParser.logMessage(message.getString("message"));
|
||||
return MessageStatus.PROCESSED;
|
||||
|
||||
} else if ("notify-loaded".equals(type)) {
|
||||
mJavaBridgeLoaded = true;
|
||||
return MessageStatus.PROCESSED;
|
||||
|
||||
} else if ("sync-reply".equals(type)) {
|
||||
// Reply to Java-to-Javascript sync call
|
||||
return MessageStatus.REPLIED;
|
||||
|
@ -1157,6 +1157,8 @@ function JavaBridge(obj) {
|
||||
// The number of replies needed to answer all outstanding sync calls.
|
||||
this._repliesNeeded = 0;
|
||||
this._Services.obs.addObserver(this, this._EVENT_TYPE, false);
|
||||
|
||||
this._sendMessage("notify-loaded", []);
|
||||
};
|
||||
|
||||
JavaBridge.prototype = {
|
||||
|
Loading…
Reference in New Issue
Block a user