Have a try with the following code change in testExtensionBroadcast:

```
getInstrumentation().runOnMainSync(new Runnable() {
  @Override
  public void run() {
    new ExtensionBroadcast();
  }
});
```

In this sense, the extension creation and HTML loading (via loadDataSync) happen on the same thread.