Bug 1181601 - Preloaded remote browsers don't have RemoteWebProgress initialized in time
The problem appears to be that any preloaded about:newtab browsers after the first preloaded about:newtab browser cannot communicate with the parent.

Hypothesis:

The reason that the first preloaded newtab works, but not the others is because the first preloaded newtab is somehow ruining things for future about:newtabs.

Experiment:

Eliminate all error messages via the hackiest means possible to see if that influences the other preloaded about:newtab pages.

This did not fix the issue.

Experiment:

See if there's any console spew from a debug build that might explain why messages are not being dispatched properly

[Parent 59writeAtomic435] WARNING: 'aTabParent != sActiveTabParent', file /Users/mikeconley/Projects/mozilla-central/dom/events/IMEStateManager.cpp, line 948
[Child 59437] WARNING: nsWindow::GetNativeData not implemented for this type: file /Users/mikeconley/Projects/mozilla-central/widget/PuppetWidget.cpp, line 1068
++DOCSHELL 0x121d53000 == 5 [pid = 59437] [id = 5]
++DOMWINDOW == 10 (0x121dc4800) [pid = 59437] [serial = 12] [outer = 0x0]
[Child 59437] WARNING: NS_ENSURE_TRUE(domDoc && target) failed: file /Users/mikeconley/Projects/mozilla-central/dom/base/nsContentUtils.cpp, line 3680
[Child 59437] WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80070057: file /Users/mikeconley/Projects/mozilla-central/dom/base/nsContentUtils.cpp, line 3735
++DOMWINDOW == 11 (0x1238dd800) [pid = 59437] [serial = 13] [outer = 0x121dc4800]
*************************
A coding exception was thrown and uncaught in a Task.

Full message: TypeError: File path should be a (non-empty) string
Full stack: @resource://gre/modules/osfile/osfile_shared_front.jsm:400:1
writeAtomic@resource://gre/modules/osfile/osfile_async_worker.js:266:1
worker.dispatch@resource://gre/modules/osfile/osfile_async_worker.js:31:26
anonymous/AbstractWorker.prototype.handleMessage@resource://gre/modules/workers/PromiseWorker.js:122:16
@resource://gre/modules/osfile/osfile_async_worker.js:46:43

*************************
*************************
A coding exception was thrown and uncaught in a Task.

Full message: TypeError: File path should be a (non-empty) string
Full stack: writeAtomic@resource://gre/modules/osfile/osfile_shared_front.jsm:400:1
writeAtomic@resource://gre/modules/osfile/osfile_async_worker.js:266:1
worker.dispatch@resource://gre/modules/osfile/osfile_async_worker.js:31:26
anonymous/AbstractWorker.prototype.handleMessage@resource://gre/modules/workers/PromiseWorker.js:122:16
@resource://gre/modules/osfile/osfile_async_worker.js:46:43

*************************
*************************
A coding exception was thrown and uncaught in a Task.

Full message: TypeError: File path should be a (non-empty) string
Full stack: writeAtomic@resource://gre/modules/osfile/osfile_shared_front.jsm:400:1
writeAtomic@resource://gre/modules/osfile/osfile_async_worker.js:266:1
worker.dispatch@resource://gre/modules/osfile/osfile_async_worker.js:31:26
anonymous/AbstractWorker.prototype.handleMessage@resource://gre/modules/workers/PromiseWorker.js:122:16
@resource://gre/modules/osfile/osfile_async_worker.js:46:43

*************************
[Child 59437] WARNING: '!editorRectEvent.mSucceeded', file /Users/mikeconley/Projects/mozilla-central/widget/ContentCache.cpp, line 254
[Child 59437] WARNING: '!mContentCache.CacheEditorRect(this, &aIMENotification)', file /Users/mikeconley/Projects/mozilla-central/widget/PuppetWidget.cpp, line 829
[Child 59437] WARNING: NS_ENSURE_SUCCESS(rv, true) failed with result 0x80570030: file /Users/mikeconley/Projects/mozilla-central/docshell/base/nsDocShell.cpp, line 11758
++DOMWINDOW == 12 (0x123aae800) [pid = 59437] [serial = 14] [outer = 0x121dc4800]
SENDING MESSAGE WITH:
about:newtab
about:newtab

Sending message: NewTab:RegisterPage
I REGISTERD THIS PAGE

Sending message: NewTab:InitializeGrid

Sending message: RemotePage:Load
--DOMWINDOW == 27 (0x130a31000) [pid = 59435] [serial = 8] [outer = 0x129d6a400] [url = about:blank]
--DOMWINDOW == 11 (0x1238dd800) [pid = 59437] [serial = 13] [outer = 0x121dc4800] [url = about:blank]

No - nothing interesting in here.

Experiment:

Set up a message listener directly to the preloaded browser that just dumps to the console when Content:LocationChange is sent. Very simple, stripped down, without any other machinery.

Ah hah! We just learned that the message for onLocationChange is being sent up, but that the message listener in RemoteWebProgress.jsm is not getting it for some reason.

Question: Why is RemoteWebProgress not getting the message that is being sent up from the content (and we know it's being sent up).

AH HAH

I think I know what's going on!

I believe the problem is that the remote-browser.xml binding is not being attached properly to the preloaded browser!

THE REASON : The problem is that the RemoteWebProgress is constructed lazily, and the preloaded browser sends up a message with updates before the RemoteWebProgress has a chance to be loaded and attached. So the reason that the messages aren't being received is because the RemoteWebProgress is created too late!

  1. For the preloaded browser, make sure that RemoteWebNavigation is loaded when the preloaded browser is created
  2. In browser.js's _loadURIWithFlags, we need to figure out what path the preloaded browser goes through, and make sure that we somehow call webProgress - this will cause us to instantiate RemoteWebProgress, which sets up the listeners, and bobs your uncle.

Renamed from Unable to receive messages from preloaded, remote newtab page to Preloaded remote browsers don't have RemoteWebProgress initialized in time