Bug 1415297 - Dispatch TabEvents.LOADED again on DOMContentLoaded. r?sebastian
AddToHomeScreenPromotion uses this for triggering the self-same promotion and
the BrowserToolbar uses it to update its progress display.
MozReview-Commit-ID: 1xrwjWP5Idh
--- a/mobile/android/base/java/org/mozilla/gecko/Tabs.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tabs.java
@@ -149,16 +149,17 @@ public class Tabs implements BundleEvent
null);
EventDispatcher.getInstance().registerUiThreadListener(this,
"Content:LocationChange",
"Content:SubframeNavigation",
"Content:SecurityChange",
"Content:StateChange",
"Content:LoadError",
+ "Content:DOMContentLoaded",
"Content:PageShow",
"Content:DOMTitleChanged",
"DesktopMode:Changed",
"Link:Favicon",
"Link:Feed",
"Link:Manifest",
"Link:OpenSearch",
"Link:Touchicon",
@@ -634,16 +635,20 @@ public class Tabs implements BundleEvent
tab.handleDocumentStop(message.getBoolean("success"));
notifyListeners(tab, Tabs.TabEvents.STOP);
}
} else if ("Content:LoadError".equals(event)) {
tab.handleContentLoaded();
notifyListeners(tab, Tabs.TabEvents.LOAD_ERROR);
+ } else if ("Content:DOMContentLoaded".equals(event)) {
+ tab.handleContentLoaded();
+ notifyListeners(tab, TabEvents.LOADED);
+
} else if ("Content:PageShow".equals(event)) {
tab.setLoadedFromCache(message.getBoolean("fromCache"));
tab.updateUserRequested(message.getString("userRequested"));
notifyListeners(tab, TabEvents.PAGE_SHOW);
} else if ("Content:DOMTitleChanged".equals(event)) {
tab.updateTitle(message.getString("title"));
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/AboutHomeTest.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/AboutHomeTest.java
@@ -80,17 +80,17 @@ abstract class AboutHomeTest extends Pix
mAsserter.ok(isCorrect, "Checking that " + url + " displayed as a bookmark", url + " displayed");
}
// Loads a bookmark by tapping on the bookmark view in the Bookmarks tab
protected void loadBookmark(String url) {
View bookmark = getDisplayedBookmark(url);
if (bookmark != null) {
Actions.EventExpecter contentEventExpecter =
- mActions.expectGlobalEvent(Actions.EventType.GECKO, "Content:DOMContentLoaded");
+ mActions.expectGlobalEvent(Actions.EventType.UI, "Content:DOMContentLoaded");
mSolo.clickOnView(bookmark);
contentEventExpecter.blockForEvent();
contentEventExpecter.unregisterListener();
} else {
mAsserter.ok(false, url + " is not one of the displayed bookmarks", "Please make sure the url provided is bookmarked");
}
}
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/OldBaseTest.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/OldBaseTest.java
@@ -153,17 +153,17 @@ abstract class OldBaseTest extends BaseR
protected final Fragment getBrowserSearch() {
final FragmentManager fm = ((FragmentActivity) getActivity()).getSupportFragmentManager();
return fm.findFragmentByTag("browser_search");
}
protected final void hitEnterAndWait() {
Actions.EventExpecter contentEventExpecter =
- mActions.expectGlobalEvent(Actions.EventType.GECKO, "Content:DOMContentLoaded");
+ mActions.expectGlobalEvent(Actions.EventType.UI, "Content:DOMContentLoaded");
mActions.sendSpecialKey(Actions.SpecialKey.ENTER);
// wait for screen to load
contentEventExpecter.blockForEvent();
contentEventExpecter.unregisterListener();
}
/**
* Load <code>url</code> by sending key strokes to the URL bar UI.
@@ -197,17 +197,17 @@ abstract class OldBaseTest extends BaseR
}
/**
* Load <code>url</code> using the internal
* <code>org.mozilla.gecko.Tabs</code> API and wait for DOMContentLoaded.
*/
protected final void loadUrlAndWait(final String url) {
Actions.EventExpecter contentEventExpecter =
- mActions.expectGlobalEvent(Actions.EventType.GECKO, "Content:DOMContentLoaded");
+ mActions.expectGlobalEvent(Actions.EventType.UI, "Content:DOMContentLoaded");
loadUrl(url);
contentEventExpecter.blockForEvent();
contentEventExpecter.unregisterListener();
}
protected final void closeTab(int tabId) {
Tabs tabs = Tabs.getInstance();
Tab tab = tabs.getTab(tabId);
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/helpers/WaitHelper.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/helpers/WaitHelper.java
@@ -115,17 +115,17 @@ public final class WaitHelper {
// state.
final ChangeVerifier[] pageLoadVerifiers = PAGE_LOAD_VERIFIERS;
for (final ChangeVerifier verifier : pageLoadVerifiers) {
verifier.storeState();
}
// Wait for the page load and title changed event.
final EventExpecter[] eventExpecters = new EventExpecter[] {
- sActions.expectGlobalEvent(Actions.EventType.GECKO, "Content:DOMContentLoaded"),
+ sActions.expectGlobalEvent(Actions.EventType.UI, "Content:DOMContentLoaded"),
sActions.expectGlobalEvent(Actions.EventType.UI, "Content:DOMTitleChanged")
};
initiatingAction.run();
// PAGE_LOAD_WAIT_MS is the total time we wait for all events to finish.
final long expecterStartMillis = SystemClock.uptimeMillis();
for (final EventExpecter expecter : eventExpecters) {
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAboutPage.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAboutPage.java
@@ -25,17 +25,17 @@ public class testAboutPage extends Pixel
url = getAbsoluteUrl(mStringHelper.ROBOCOP_BLANK_PAGE_01_URL);
loadUrlAndWait(url);
// At this point the page title should have been set.
verifyUrlInContentDescription(url);
// Set up listeners to catch the page load we're about to do.
Actions.EventExpecter tabEventExpecter = mActions.expectGlobalEvent(Actions.EventType.UI, "Tab:Added");
- Actions.EventExpecter contentEventExpecter = mActions.expectGlobalEvent(Actions.EventType.GECKO, "Content:DOMContentLoaded");
+ Actions.EventExpecter contentEventExpecter = mActions.expectGlobalEvent(Actions.EventType.UI, "Content:DOMContentLoaded");
selectSettingsItem(mStringHelper.MOZILLA_SECTION_LABEL, mStringHelper.ABOUT_LABEL);
// Wait for the new tab and page to load
tabEventExpecter.blockForEvent();
contentEventExpecter.blockForEvent();
tabEventExpecter.unregisterListener();
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAddonManager.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAddonManager.java
@@ -25,17 +25,17 @@ public class testAddonManager extends Pi
blockForGeckoReady();
// Use the menu to open the Addon Manger
selectMenuItem(mStringHelper.ADDONS_LABEL);
// Set up listeners to catch the page load we're about to do
tabEventExpecter = mActions.expectGlobalEvent(Actions.EventType.UI, "Tab:Added");
- contentEventExpecter = mActions.expectGlobalEvent(Actions.EventType.GECKO, "Content:DOMContentLoaded");
+ contentEventExpecter = mActions.expectGlobalEvent(Actions.EventType.UI, "Content:DOMContentLoaded");
// Wait for the new tab and page to load
tabEventExpecter.blockForEvent();
contentEventExpecter.blockForEvent();
tabEventExpecter.unregisterListener();
contentEventExpecter.unregisterListener();
@@ -46,17 +46,17 @@ public class testAddonManager extends Pi
mSolo.goBack();
// Load the about:addons page and verify it was loaded
loadAndPaint(aboutAddonsURL);
verifyUrlBarTitle(aboutAddonsURL);
// Setup wait for tab to spawn and load
tabEventExpecter = mActions.expectGlobalEvent(Actions.EventType.UI, "Tab:Added");
- contentEventExpecter = mActions.expectGlobalEvent(Actions.EventType.GECKO, "Content:DOMContentLoaded");
+ contentEventExpecter = mActions.expectGlobalEvent(Actions.EventType.UI, "Content:DOMContentLoaded");
// Open a new tab
final String blankURL = getAbsoluteUrl(mStringHelper.ROBOCOP_BLANK_PAGE_01_URL);
addTab(blankURL);
// Wait for the new tab and page to load
tabEventExpecter.blockForEvent();
contentEventExpecter.blockForEvent();