Closed Bug 1253467 Opened 8 years ago Closed 6 years ago

Java-side JavascriptBridge will not receive messages from js if js.syncCall returns (including assertions)

Categories

(Firefox for Android Graveyard :: Testing, defect)

All
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: mcomella, Unassigned)

Details

Attachments

(1 file)

So I can't:

Java---
js.syncCall('getPromiseValue');

JS---
function getPromiseValue() {
  aPromise().then(function (ret) {
    java.asyncCall('gotPromiseValue', ret);
  });
}

---
Either we should add to the documentation saying this is intended, or fix it.

Jim, is this expected?
Flags: needinfo?(nchen)
Assignee: nobody → michael.l.comella
Status: NEW → ASSIGNED
Assignee: michael.l.comella → nobody
Status: ASSIGNED → NEW
To be more explicit with comment 0:

Java---
public void mainTest() {
  js.syncCall('getPromiseValue');
  spinAndWaitForJSCallToFinish();
}

public void gotPromiseValue(String ret) {
  // Never called.
}

public void spinAndWaitForJSCallToFinish() {
  // Do some Thread.sleep action in here until timeout
}

JS---
function getPromiseValue() {
  aPromise().then(function (ret) {
    java.asyncCall('gotPromiseValue', ret);
  });
}

I also replaced `java.asyncCall...` with `do_check_false(true)` and the test completed successfully, rather than failing as expected. It appears that all js -> java messages are ignored once js.syncCall returns. We can't use js.asyncCall because the test will return.
Summary: JavascriptBridge will not receive javascript messages if js.syncCall returns → Java-side JavascriptBridge will not receive messages from js if js.syncCall returns (including assertions)
So your call will only go through if you wait for a call, which happens inside syncCall(). Otherwise, your test thread is busy doing other stuff (sleeping in this case), and the test thread doesn't get an opportunity to actually run the called method (because it's spending time inside Thread.sleep). If you put a dummy syncCall (e.g. js.syncCall("pollJs")) in the loop before you call Thread.sleep,  your async call should go through as well.
Flags: needinfo?(nchen)
And if we want to "fix" this behavior, we should probably teach the JS side (i.e. JavaBridge) how to handle promises.
Mass closing Firefox for Android :: Testing bugs with no progress in 2017.

If this bug is important to you, please re-open.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: