Bug 860899 - Fixup metro mochitests r=jimm
authorRodrigo Silveira <rsilveira@mozilla.com>
Tue, 14 May 2013 23:30:24 -0700
changeset 132161 630a7d5a7ceb9cca74a32aba08d22b95f7c2ffe2
parent 132160 2d47bbb35842236cbbf6a62eae00311290190b15
child 132162 da470133a9ba07b9e5b4a6d1d93bfa8b84544ef5
child 132185 ea767da526ffca2ae068a0c677a6c5bc16cdecdc
push id28150
push userrsilveira@mozilla.com
push dateThu, 16 May 2013 22:37:59 +0000
treeherdermozilla-inbound@630a7d5a7ceb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs860899
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 860899 - Fixup metro mochitests r=jimm
browser/metro/base/tests/mochitest/Makefile.in
browser/metro/base/tests/mochitest/browser_bookmarks.js
browser/metro/base/tests/mochitest/browser_context_menu_tests.js
browser/metro/base/tests/mochitest/browser_history.js
browser/metro/base/tests/mochitest/browser_selection_basic.html
browser/metro/base/tests/mochitest/browser_selection_frame_content.html
browser/metro/base/tests/mochitest/browser_selection_frame_content.js
browser/metro/base/tests/mochitest/browser_selection_frame_inputs.html
browser/metro/base/tests/mochitest/browser_selection_frame_inputs.js
browser/metro/base/tests/mochitest/browser_selection_frame_textarea.html
browser/metro/base/tests/mochitest/browser_selection_frame_textarea.js
browser/metro/base/tests/mochitest/browser_selection_inputs.js
browser/metro/base/tests/mochitest/head.js
--- a/browser/metro/base/tests/mochitest/Makefile.in
+++ b/browser/metro/base/tests/mochitest/Makefile.in
@@ -7,34 +7,34 @@ topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 relativesrcdir  = @relativesrcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 BROWSER_TESTS = \
   head.js \
-  browser_test.js \
+  browser_bookmarks.js \
   browser_canonizeURL.js \
-  browser_context_ui.js \
-  browser_tiles.js \
-  browser_tilegrid.xul \
-  browser_onscreen_keyboard.js \
-  browser_onscreen_keyboard.html \
-  browser_remotetabs.js \
-  browser_downloads.js \
   browser_context_menu_tests.js \
   browser_context_menu_tests_01.html \
   browser_context_menu_tests_02.html \
   browser_context_menu_tests_03.html \
+  browser_context_ui.js \
+  browser_downloads.js \
+  browser_history.js \
+  browser_onscreen_keyboard.js \
+  browser_onscreen_keyboard.html \
   browser_prefs_ui.js \
-  browser_topsites.js \
+  browser_remotetabs.js \
   browser_tabs.js \
-  browser_bookmarks.js \
-  browser_history.js \
+  browser_test.js \
+  browser_tiles.js \
+  browser_tilegrid.xul \
+  browser_topsites.js \
   $(NULL)
 
 # disabled due to timeouts and lack of plugin support.
 #  browser_plugin_input.html \
 #  browser_plugin_input_mouse.js \
 #  browser_plugin_input_keyboard.js \
 
 ifndef MOZ_DEBUG
@@ -53,16 +53,17 @@ BROWSER_TESTS += \
   browser_selection_frame_inputs.html \
   $(NULL)
 endif
 
 BROWSER_TEST_RESOURCES = \
   res/image01.png \
   res/textblock01.html \
   res/textinput01.html \
+  res/textarea01.html \
   $(NULL)
 
 libs:: $(BROWSER_TESTS)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/metro/$(relativesrcdir)
 
 libs:: $(BROWSER_TEST_RESOURCES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/metro/$(relativesrcdir)/res
 
--- a/browser/metro/base/tests/mochitest/browser_bookmarks.js
+++ b/browser/metro/base/tests/mochitest/browser_bookmarks.js
@@ -11,24 +11,24 @@ let gPanelView = BookmarksPanelView._vie
 function test() {
   runTests();
 }
 
 function setup() {
   PanelUI.hide();
   BookmarksTestHelper.setup();
 
+  yield hideContextUI();
+
   if (StartUI.isStartPageVisible)
     return;
 
   yield addTab("about:start");
 
   yield waitForCondition(() => StartUI.isStartPageVisible);
-
-  yield hideContextUI();
 }
 
 function tearDown() {
   PanelUI.hide();
   BookmarksTestHelper.restore();
 }
 
 var BookmarksTestHelper = {
@@ -144,47 +144,47 @@ gTests.push({
   tearDown: tearDown,
   run: function testBookmarksStartUnpin() {
     let unpinButton = document.getElementById("unpin-selected-button");
 
     // --------- unpin item 2
 
     let item = gStartView._getItemForBookmarkId(2);
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item, 10, 10);
     yield promise;
 
     ok(!unpinButton.hidden, "Unpin button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
-    EventUtils.synthesizeMouse(unpinButton, 10, 10, {}, window);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
+    unpinButton.click();
     yield promise;
 
     item = gStartView._getItemForBookmarkId(2);
 
     ok(!item, "Item not in grid");
     ok(!gStartView._pinHelper.isPinned(2), "Item unpinned");
     ok(gStartView._set.itemCount === gStartView._limit, "Grid repopulated");
 
     // --------- unpin multiple items
 
     let item1 = gStartView._getItemForBookmarkId(0);
     let item2 = gStartView._getItemForBookmarkId(5);
     let item3 = gStartView._getItemForBookmarkId(12);
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item1, 10, 10);
     sendContextMenuClickToElement(window, item2, 10, 10);
     sendContextMenuClickToElement(window, item3, 10, 10);
     yield promise;
 
     ok(!unpinButton.hidden, "Unpin button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     EventUtils.synthesizeMouse(unpinButton, 10, 10, {}, window);
     yield promise;
 
     item1 = gStartView._getItemForBookmarkId(0);
     item2 = gStartView._getItemForBookmarkId(5);
     item3 = gStartView._getItemForBookmarkId(12);
 
     ok(!item1 && !item2 && !item3, "Items are not in grid");
@@ -201,63 +201,63 @@ gTests.push({
     let restoreButton = document.getElementById("restore-selected-button");
     let deleteButton = document.getElementById("delete-selected-button");
 
     // --------- delete item 2 and restore
 
     let item = gStartView._getItemForBookmarkId(2);
     let initialLocation = gStartView._set.getIndexOfItem(item);
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item, 10, 10);
     yield promise;
 
     ok(!deleteButton.hidden, "Delete button is visible.");
 
     let promise = waitForCondition(() => !restoreButton.hidden);
     EventUtils.synthesizeMouse(deleteButton, 10, 10, {}, window);
     yield promise;
 
     item = gStartView._getItemForBookmarkId(2);
 
     ok(!item, "Item not in grid");
     ok(BookmarksTestHelper._nodes[2], "Item not deleted yet");
     ok(!restoreButton.hidden, "Restore button is visible.");
     ok(gStartView._set.itemCount === gStartView._limit, "Grid repopulated");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     EventUtils.synthesizeMouse(restoreButton, 10, 10, {}, window);
     yield promise;
 
     item = gStartView._getItemForBookmarkId(2);
     ok(item, "Item back in grid");
     ok(gStartView._set.getIndexOfItem(item) === initialLocation, "Back in same position.");
 
     // --------- delete item 2 for realz
 
     let item = gStartView._getItemForBookmarkId(2);
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item, 10, 10);
     yield promise;
 
     ok(!deleteButton.hidden, "Delete button is visible.");
 
     let promise = waitForCondition(() => !restoreButton.hidden);
     EventUtils.synthesizeMouse(deleteButton, 10, 10, {}, window);
     yield promise;
 
     item = gStartView._getItemForBookmarkId(2);
 
     ok(!item, "Item not in grid");
     ok(BookmarksTestHelper._nodes[2], "Item not deleted yet");
     ok(!restoreButton.hidden, "Restore button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
-    Elements.appbar.dismiss();
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
+    Elements.contextappbar.dismiss();
     yield promise;
 
     item = gStartView._getItemForBookmarkId(2);
 
     ok(!item, "Item not in grid");
     ok(!BookmarksTestHelper._nodes[2], "Item RIP");
     ok(gStartView._set.itemCount === gStartView._limit, "Grid repopulated");
 
@@ -266,17 +266,17 @@ gTests.push({
     let item1 = gStartView._getItemForBookmarkId(0);
     let item2 = gStartView._getItemForBookmarkId(5);
     let item3 = gStartView._getItemForBookmarkId(12);
 
     let initialLocation1 = gStartView._set.getIndexOfItem(item1);
     let initialLocation2 = gStartView._set.getIndexOfItem(item2);
     let initialLocation3 = gStartView._set.getIndexOfItem(item3);
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item1, 10, 10);
     sendContextMenuClickToElement(window, item2, 10, 10);
     sendContextMenuClickToElement(window, item3, 10, 10);
     yield promise;
 
     ok(!deleteButton.hidden, "Delete button is visible.");
 
     let promise = waitForCondition(() => !restoreButton.hidden);
@@ -288,17 +288,17 @@ gTests.push({
     item3 = gStartView._getItemForBookmarkId(12);
 
     ok(!item1 && !item2 && !item3, "Items are not in grid");
     ok(BookmarksTestHelper._nodes[0] && BookmarksTestHelper._nodes[5] && BookmarksTestHelper._nodes[12],
       "Items not deleted yet");
     ok(!restoreButton.hidden, "Restore button is visible.");
     ok(gStartView._set.itemCount === gStartView._limit - 1, "Grid repopulated");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     EventUtils.synthesizeMouse(restoreButton, 10, 10, {}, window);
     yield promise;
 
     item1 = gStartView._getItemForBookmarkId(0);
     item2 = gStartView._getItemForBookmarkId(5);
     item3 = gStartView._getItemForBookmarkId(12);
 
     ok(item1 && item2 && item3, "Items are back in grid");
@@ -308,17 +308,17 @@ gTests.push({
     ok(gStartView._set.itemCount === gStartView._limit, "Grid repopulated");
 
     // --------- delete multiple items for good
 
     let item1 = gStartView._getItemForBookmarkId(0);
     let item2 = gStartView._getItemForBookmarkId(5);
     let item3 = gStartView._getItemForBookmarkId(12);
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item1, 10, 10);
     sendContextMenuClickToElement(window, item2, 10, 10);
     sendContextMenuClickToElement(window, item3, 10, 10);
     yield promise;
 
     ok(!deleteButton.hidden, "Delete button is visible.");
 
     let promise = waitForCondition(() => !restoreButton.hidden);
@@ -329,18 +329,18 @@ gTests.push({
     item2 = gStartView._getItemForBookmarkId(5);
     item3 = gStartView._getItemForBookmarkId(12);
 
     ok(!item1 && !item2 && !item3, "Items are not in grid");
     ok(BookmarksTestHelper._nodes[0] && BookmarksTestHelper._nodes[5] && BookmarksTestHelper._nodes[12],
       "Items not deleted yet");
     ok(!restoreButton.hidden, "Restore button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
-    Elements.appbar.dismiss();
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
+    Elements.contextappbar.dismiss();
     yield promise;
 
     item1 = gStartView._getItemForBookmarkId(0);
     item2 = gStartView._getItemForBookmarkId(5);
     item3 = gStartView._getItemForBookmarkId(12);
 
     ok(!item1 && !item2 && !item3, "Items are not in grid");
     ok(!BookmarksTestHelper._nodes[0] && !BookmarksTestHelper._nodes[5] && !BookmarksTestHelper._nodes[12],
@@ -358,48 +358,50 @@ gTests.push({
 
     let pinButton = document.getElementById("pin-selected-button");
     let unpinButton = document.getElementById("unpin-selected-button");
 
     // --------- unpin item 2
 
     let item = gPanelView._getItemForBookmarkId(2);
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item, 10, 10);
     yield promise;
 
+    yield waitForCondition(() => !unpinButton.hidden);
+
     ok(!unpinButton.hidden, "Unpin button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     EventUtils.synthesizeMouse(unpinButton, 10, 10, {}, window);
     yield promise;
 
     item = gPanelView._getItemForBookmarkId(2);
     let startItem = gStartView._getItemForBookmarkId(2);
 
     ok(item, "Item is in grid");
     ok(!startItem, "Item not in start grid");
     ok(!gPanelView._pinHelper.isPinned(2), "Item unpinned");
 
     // --------- unpin multiple items
 
     let item1 = gPanelView._getItemForBookmarkId(0);
     let item2 = gPanelView._getItemForBookmarkId(5);
     let item3 = gPanelView._getItemForBookmarkId(12);
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item1, 10, 10);
     sendContextMenuClickToElement(window, item2, 10, 10);
     sendContextMenuClickToElement(window, item3, 10, 10);
     yield promise;
 
     ok(!unpinButton.hidden, "Unpin button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     EventUtils.synthesizeMouse(unpinButton, 10, 10, {}, window);
     yield promise;
 
     item1 = gPanelView._getItemForBookmarkId(0);
     item2 = gPanelView._getItemForBookmarkId(5);
     item3 = gPanelView._getItemForBookmarkId(12);
     let startItem1 = gStartView._getItemForBookmarkId(0);
     let startItem2 = gStartView._getItemForBookmarkId(5);
@@ -408,54 +410,54 @@ gTests.push({
     ok(item1 && item2 && item3, "Items are in grid");
     ok(!startItem1 && !startItem2 && !startItem3, "Items are not in start grid");
     ok(!gPanelView._pinHelper.isPinned(0) && !gPanelView._pinHelper.isPinned(5) && !gPanelView._pinHelper.isPinned(12) , "Items unpinned");
 
     // --------- pin item 2
 
     let item = gPanelView._getItemForBookmarkId(2);
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item, 10, 10);
     yield promise;
 
     // Make sure app bar is updated
     yield waitForCondition(() => !pinButton.hidden);
 
     ok(!pinButton.hidden, "Pin button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     EventUtils.synthesizeMouse(pinButton, 10, 10, {}, window);
     yield promise;
 
     item = gPanelView._getItemForBookmarkId(2);
     let startItem = gStartView._getItemForBookmarkId(2);
 
     ok(item, "Item is in grid");
     ok(startItem, "Item is back in start grid");
     ok(gPanelView._pinHelper.isPinned(2), "Item pinned");
 
     // --------- pin multiple items
 
     let item1 = gPanelView._getItemForBookmarkId(0);
     let item2 = gPanelView._getItemForBookmarkId(5);
     let item3 = gPanelView._getItemForBookmarkId(12);
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item1, 10, 10);
     sendContextMenuClickToElement(window, item2, 10, 10);
     sendContextMenuClickToElement(window, item3, 10, 10);
     yield promise;
 
     // Make sure app bar is updated
     yield waitForCondition(() => !pinButton.hidden);
 
     ok(!pinButton.hidden, "pin button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     EventUtils.synthesizeMouse(pinButton, 10, 10, {}, window);
     yield promise;
 
     item1 = gPanelView._getItemForBookmarkId(0);
     item2 = gPanelView._getItemForBookmarkId(5);
     item3 = gPanelView._getItemForBookmarkId(12);
     let startItem1 = gStartView._getItemForBookmarkId(0);
     let startItem2 = gStartView._getItemForBookmarkId(5);
@@ -476,17 +478,17 @@ gTests.push({
 
     let restoreButton = document.getElementById("restore-selected-button");
     let deleteButton = document.getElementById("delete-selected-button");
 
     // --------- delete item 2
 
     let item = gPanelView._getItemForBookmarkId(2);
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item, 10, 10);
     yield promise;
 
     ok(!deleteButton.hidden, "Delete button is visible.");
 
     let promise = waitForCondition(() => !restoreButton.hidden);
     EventUtils.synthesizeMouse(deleteButton, 10, 10, {}, window);
     yield promise;
@@ -494,34 +496,34 @@ gTests.push({
     item = gPanelView._getItemForBookmarkId(2);
     let startItem = gStartView._getItemForBookmarkId(2);
 
     ok(!item, "Item is not in grid");
     ok(startItem, "Item is not deleted from start grid yet");
     ok(BookmarksTestHelper._nodes[2], "Item exists");
     ok(!restoreButton.hidden, "Restore button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
-    Elements.appbar.dismiss();
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
+    Elements.contextappbar.dismiss();
     yield promise;
 
     item = gPanelView._getItemForBookmarkId(2);
     startItem = gStartView._getItemForBookmarkId(2);
 
     ok(!item, "Item gone from grid");
     ok(!startItem, "Item gone from start grid");
     ok(!BookmarksTestHelper._nodes[2], "Item RIP");
 
     // --------- delete multiple items
 
     let item1 = gPanelView._getItemForBookmarkId(0);
     let item2 = gPanelView._getItemForBookmarkId(5);
     let item3 = gPanelView._getItemForBookmarkId(12);
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item1, 10, 10);
     sendContextMenuClickToElement(window, item2, 10, 10);
     sendContextMenuClickToElement(window, item3, 10, 10);
     yield promise;
 
     ok(!deleteButton.hidden, "Delete button is visible.");
 
     let promise = waitForCondition(() => !restoreButton.hidden);
@@ -536,18 +538,18 @@ gTests.push({
     let startItem3 = gStartView._getItemForBookmarkId(12);
 
     ok(!restoreButton.hidden, "Restore button is visible.");
     ok(!item1 && !item2 && !item3, "Items are not in grid");
     ok(startItem1 && startItem2 && startItem3, "Items are still in start grid");
     ok(BookmarksTestHelper._nodes[0] && BookmarksTestHelper._nodes[5] && BookmarksTestHelper._nodes[12],
       "Items not deleted yet");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend");
-    Elements.appbar.dismiss();
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
+    Elements.contextappbar.dismiss();
     yield promise;
 
     item1 = gPanelView._getItemForBookmarkId(0);
     item2 = gPanelView._getItemForBookmarkId(5);
     item3 = gPanelView._getItemForBookmarkId(12);
     let startItem1 = gStartView._getItemForBookmarkId(0);
     let startItem2 = gStartView._getItemForBookmarkId(5);
     let startItem3 = gStartView._getItemForBookmarkId(12);
--- a/browser/metro/base/tests/mochitest/browser_context_menu_tests.js
+++ b/browser/metro/base/tests/mochitest/browser_context_menu_tests.js
@@ -45,16 +45,18 @@ gTests.push({
 
     ////////////////////////////////////////////////////////////
     // Context menu in content on selected text
 
     // select some text
     let span = win.document.getElementById("text1");
     win.getSelection().selectAllChildren(span);
 
+    yield waitForMs(0);
+
     // invoke selection context menu
     let promise = waitForEvent(document, "popupshown");
     sendContextMenuClickToElement(win, span, 85, 10);
     yield promise;
 
     // should be visible
     ok(ContextMenuUI._menuPopup._visible, "is visible");
 
@@ -278,16 +280,17 @@ gTests.push({
     promise = waitForEvent(document, "popuphidden");
     ContextMenuUI.hide();
     yield promise;
 
     ////////////////////////////////////////////////////////////
     // context in empty input, no data on clipboard (??)
 
     emptyClipboard();
+    ContextUI.dismiss();
 
     input = win.document.getElementById("text3-input");
     input.value = "";
 
     promise = waitForEvent(Elements.tray, "transitionend");
     sendContextMenuClickToElement(win, input, 20, 10);
     yield promise;
 
--- a/browser/metro/base/tests/mochitest/browser_history.js
+++ b/browser/metro/base/tests/mochitest/browser_history.js
@@ -139,47 +139,47 @@ gTests.push({
   tearDown: tearDown,
   run: function testHistoryStartUnpin() {
     let unpinButton = document.getElementById("unpin-selected-button");
 
     // --------- unpin item 2
 
     let item = gStartView._set.getItemsByUrl(uriFromIndex(2))[0];
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item, 10, 10);
     yield promise;
 
     ok(!unpinButton.hidden, "Unpin button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     unpinButton.click();
     yield promise;
 
     item = gStartView._set.getItemsByUrl(uriFromIndex(2))[0];
 
     ok(!item, "Item not in grid");
     ok(!gStartView._pinHelper.isPinned(uriFromIndex(2)), "Item unpinned");
     ok(gStartView._set.itemCount === gStartView._limit, "Grid repopulated");
 
     // --------- unpin multiple items
 
     let item1 = gStartView._set.getItemsByUrl(uriFromIndex(0))[0];
     let item2 = gStartView._set.getItemsByUrl(uriFromIndex(5))[0];
     let item3 = gStartView._set.getItemsByUrl(uriFromIndex(12))[0];
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item1, 10, 10);
     sendContextMenuClickToElement(window, item2, 10, 10);
     sendContextMenuClickToElement(window, item3, 10, 10);
     yield promise;
 
     ok(!unpinButton.hidden, "Unpin button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     EventUtils.synthesizeMouse(unpinButton, 10, 10, {}, window);
     yield promise;
 
     item1 = gStartView._set.getItemsByUrl(uriFromIndex(0))[0];
     item2 = gStartView._set.getItemsByUrl(uriFromIndex(5))[0];
     item3 = gStartView._set.getItemsByUrl(uriFromIndex(12))[0];
 
     ok(!item1 && !item2 && !item3, "Items are not in grid");
@@ -196,47 +196,47 @@ gTests.push({
     let restoreButton = document.getElementById("restore-selected-button");
     let deleteButton = document.getElementById("delete-selected-button");
 
     // --------- delete item 2 and restore
 
     let item = gStartView._set.getItemsByUrl(uriFromIndex(2))[0];
     let initialLocation = gStartView._set.getIndexOfItem(item);
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item, 10, 10);
     yield promise;
 
     ok(!deleteButton.hidden, "Delete button is visible.");
 
     let promise = waitForCondition(() => !restoreButton.hidden);
     EventUtils.synthesizeMouse(deleteButton, 10, 10, {}, window);
     yield promise;
 
     item = gStartView._set.getItemsByUrl(uriFromIndex(2))[0];
 
     ok(!item, "Item not in grid");
     ok(HistoryTestHelper._nodes[uriFromIndex(2)], "Item not deleted yet");
     ok(!restoreButton.hidden, "Restore button is visible.");
     ok(gStartView._set.itemCount === gStartView._limit, "Grid repopulated");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     EventUtils.synthesizeMouse(restoreButton, 10, 10, {}, window);
     yield promise;
 
     item = gStartView._set.getItemsByUrl(uriFromIndex(2))[0];
     ok(item, "Item back in grid");
     ok(gStartView._set.getIndexOfItem(item) === initialLocation, "Back in same position.");
     ok(gStartView._set.itemCount === gStartView._limit, "Grid repopulated");
 
     // --------- delete item 2 for realz
 
     let item = gStartView._set.getItemsByUrl(uriFromIndex(2))[0];
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item, 10, 10);
     yield promise;
 
     yield waitForCondition(() => !deleteButton.hidden);
 
     ok(!deleteButton.hidden, "Delete button is visible.");
 
     let promise = waitForCondition(() => !restoreButton.hidden);
@@ -244,18 +244,18 @@ gTests.push({
     yield promise;
 
     item = gStartView._set.getItemsByUrl(uriFromIndex(2))[0];
 
     ok(!item, "Item not in grid");
     ok(HistoryTestHelper._nodes[uriFromIndex(2)], "Item not deleted yet");
     ok(!restoreButton.hidden, "Restore button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
-    Elements.appbar.dismiss();
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
+    Elements.contextappbar.dismiss();
     yield promise;
 
     item = gStartView._set.getItemsByUrl(uriFromIndex(2))[0];
 
     ok(!item, "Item not in grid");
     ok(!HistoryTestHelper._nodes[uriFromIndex(2)], "Item RIP");
     ok(gStartView._set.itemCount === gStartView._limit, "Grid repopulated");
 
@@ -264,17 +264,17 @@ gTests.push({
     let item1 = gStartView._set.getItemsByUrl(uriFromIndex(0))[0];
     let item2 = gStartView._set.getItemsByUrl(uriFromIndex(5))[0];
     let item3 = gStartView._set.getItemsByUrl(uriFromIndex(12))[0];
 
     let initialLocation1 = gStartView._set.getIndexOfItem(item1);
     let initialLocation2 = gStartView._set.getIndexOfItem(item2);
     let initialLocation3 = gStartView._set.getIndexOfItem(item3);
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item1, 10, 10);
     sendContextMenuClickToElement(window, item2, 10, 10);
     sendContextMenuClickToElement(window, item3, 10, 10);
     yield promise;
 
     yield waitForCondition(() => !deleteButton.hidden);
 
     ok(!deleteButton.hidden, "Delete button is visible.");
@@ -288,17 +288,17 @@ gTests.push({
     item3 = gStartView._set.getItemsByUrl(uriFromIndex(12))[0];
 
     ok(!item1 && !item2 && !item3, "Items are not in grid");
     ok(HistoryTestHelper._nodes[uriFromIndex(0)] && HistoryTestHelper._nodes[uriFromIndex(5)] && HistoryTestHelper._nodes[uriFromIndex(12)],
       "Items not deleted yet");
     ok(!restoreButton.hidden, "Restore button is visible.");
     ok(gStartView._set.itemCount === gStartView._limit - 1, "Grid repopulated");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     EventUtils.synthesizeMouse(restoreButton, 10, 10, {}, window);
     yield promise;
 
     item1 = gStartView._set.getItemsByUrl(uriFromIndex(0))[0];
     item2 = gStartView._set.getItemsByUrl(uriFromIndex(5))[0];
     item3 = gStartView._set.getItemsByUrl(uriFromIndex(12))[0];
 
     ok(item1 && item2 && item3, "Items are back in grid");
@@ -308,17 +308,17 @@ gTests.push({
     ok(gStartView._set.itemCount === gStartView._limit, "Grid repopulated");
 
     // --------- delete multiple items for good
 
     let item1 = gStartView._set.getItemsByUrl(uriFromIndex(0))[0];
     let item2 = gStartView._set.getItemsByUrl(uriFromIndex(5))[0];
     let item3 = gStartView._set.getItemsByUrl(uriFromIndex(12))[0];
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item1, 10, 10);
     sendContextMenuClickToElement(window, item2, 10, 10);
     sendContextMenuClickToElement(window, item3, 10, 10);
     yield promise;
 
     yield waitForCondition(() => !deleteButton.hidden);
 
     ok(!deleteButton.hidden, "Delete button is visible.");
@@ -332,18 +332,18 @@ gTests.push({
     item3 = gStartView._set.getItemsByUrl(uriFromIndex(12))[0];
 
     ok(!item1 && !item2 && !item3, "Items are not in grid");
     ok(HistoryTestHelper._nodes[uriFromIndex(0)] && HistoryTestHelper._nodes[uriFromIndex(5)] && HistoryTestHelper._nodes[uriFromIndex(12)],
       "Items not deleted yet");
     ok(!restoreButton.hidden, "Restore button is visible.");
     ok(gStartView._set.itemCount === gStartView._limit - 1, "Grid repopulated");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
-    Elements.appbar.dismiss();
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
+    Elements.contextappbar.dismiss();
     yield promise;
 
     item1 = gStartView._set.getItemsByUrl(uriFromIndex(0))[0];
     item2 = gStartView._set.getItemsByUrl(uriFromIndex(5))[0];
     item3 = gStartView._set.getItemsByUrl(uriFromIndex(12))[0];
 
     ok(!item1 && !item2 && !item3, "Items are not in grid");
     ok(!HistoryTestHelper._nodes[uriFromIndex(0)] && !HistoryTestHelper._nodes[uriFromIndex(5)] && !HistoryTestHelper._nodes[uriFromIndex(12)],
@@ -361,50 +361,50 @@ gTests.push({
 
     let pinButton = document.getElementById("pin-selected-button");
     let unpinButton = document.getElementById("unpin-selected-button");
 
     // --------- unpin item 2
 
     let item = gPanelView._set.getItemsByUrl(uriFromIndex(2))[0];
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item, 10, 10);
     yield promise;
 
     yield waitForCondition(() => !unpinButton.hidden);
 
     ok(!unpinButton.hidden, "Unpin button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     EventUtils.synthesizeMouse(unpinButton, 10, 10, {}, window);
     yield promise;
 
     item = gPanelView._set.getItemsByUrl(uriFromIndex(2))[0];
     let startItem = gStartView._set.getItemsByUrl(uriFromIndex(2))[0];
 
     ok(item, "Item is in grid");
     ok(!startItem, "Item not in start grid");
     ok(!gPanelView._pinHelper.isPinned(uriFromIndex(2)), "Item unpinned");
 
     // --------- unpin multiple items
 
     let item1 = gPanelView._set.getItemsByUrl(uriFromIndex(0))[0];
     let item2 = gPanelView._set.getItemsByUrl(uriFromIndex(5))[0];
     let item3 = gPanelView._set.getItemsByUrl(uriFromIndex(12))[0];
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item1, 10, 10);
     sendContextMenuClickToElement(window, item2, 10, 10);
     sendContextMenuClickToElement(window, item3, 10, 10);
     yield promise;
 
     ok(!unpinButton.hidden, "Unpin button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     EventUtils.synthesizeMouse(unpinButton, 10, 10, {}, window);
     yield promise;
 
     item1 = gPanelView._set.getItemsByUrl(uriFromIndex(0))[0];
     item2 = gPanelView._set.getItemsByUrl(uriFromIndex(5))[0];
     item3 = gPanelView._set.getItemsByUrl(uriFromIndex(12))[0];
     let startItem1 = gStartView._set.getItemsByUrl(uriFromIndex(0))[0];
     let startItem2 = gStartView._set.getItemsByUrl(uriFromIndex(5))[0];
@@ -413,54 +413,54 @@ gTests.push({
     ok(item1 && item2 && item3, "Items are in grid");
     ok(!startItem1 && !startItem2 && !startItem3, "Items are not in start grid");
     ok(!gPanelView._pinHelper.isPinned(uriFromIndex(0)) && !gPanelView._pinHelper.isPinned(uriFromIndex(5)) && !gPanelView._pinHelper.isPinned(uriFromIndex(12)) , "Items unpinned");
 
     // --------- pin item 2
 
     let item = gPanelView._set.getItemsByUrl(uriFromIndex(2))[0];
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item, 10, 10);
     yield promise;
 
     // Make sure app bar is updated
     yield waitForCondition(() => !pinButton.hidden);
 
     ok(!pinButton.hidden, "Pin button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     EventUtils.synthesizeMouse(pinButton, 10, 10, {}, window);
     yield promise;
 
     item = gPanelView._set.getItemsByUrl(uriFromIndex(2))[0];
     let startItem = gStartView._set.getItemsByUrl(uriFromIndex(2))[0];
 
     ok(item, "Item is in grid");
     ok(startItem, "Item is back in start grid");
     ok(gPanelView._pinHelper.isPinned(uriFromIndex(2)), "Item pinned");
 
     // --------- pin multiple items
 
     let item1 = gPanelView._set.getItemsByUrl(uriFromIndex(0))[0];
     let item2 = gPanelView._set.getItemsByUrl(uriFromIndex(5))[0];
     let item3 = gPanelView._set.getItemsByUrl(uriFromIndex(12))[0];
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item1, 10, 10);
     sendContextMenuClickToElement(window, item2, 10, 10);
     sendContextMenuClickToElement(window, item3, 10, 10);
     yield promise;
 
     // Make sure app bar is updated
     yield waitForCondition(() => !pinButton.hidden);
 
     ok(!pinButton.hidden, "pin button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     EventUtils.synthesizeMouse(pinButton, 10, 10, {}, window);
     yield promise;
 
     item1 = gPanelView._set.getItemsByUrl(uriFromIndex(0))[0];
     item2 = gPanelView._set.getItemsByUrl(uriFromIndex(5))[0];
     item3 = gPanelView._set.getItemsByUrl(uriFromIndex(12))[0];
     let startItem1 = gStartView._set.getItemsByUrl(uriFromIndex(0))[0];
     let startItem2 = gStartView._set.getItemsByUrl(uriFromIndex(5))[0];
@@ -481,17 +481,17 @@ gTests.push({
 
     let restoreButton = document.getElementById("restore-selected-button");
     let deleteButton = document.getElementById("delete-selected-button");
 
     // --------- delete item 2
 
     let item = gPanelView._set.getItemsByUrl(uriFromIndex(2))[0];
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item, 10, 10);
     yield promise;
 
     ok(!deleteButton.hidden, "Delete button is visible.");
 
     let promise = waitForCondition(() => !restoreButton.hidden);
     EventUtils.synthesizeMouse(deleteButton, 10, 10, {}, window);
     yield promise;
@@ -499,34 +499,34 @@ gTests.push({
     item = gPanelView._set.getItemsByUrl(uriFromIndex(2))[0];
     let startItem = gStartView._set.getItemsByUrl(uriFromIndex(2))[0];
 
     ok(!item, "Item is not in grid");
     ok(startItem, "Item is not deleted from start grid yet");
     ok(HistoryTestHelper._nodes[uriFromIndex(2)], "Item exists");
     ok(!restoreButton.hidden, "Restore button is visible.");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
-    Elements.appbar.dismiss();
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
+    Elements.contextappbar.dismiss();
     yield promise;
 
     item = gPanelView._set.getItemsByUrl(uriFromIndex(2))[0];
     startItem = gStartView._set.getItemsByUrl(uriFromIndex(2))[0];
 
     ok(!item, "Item gone from grid");
     ok(!startItem, "Item gone from start grid");
     ok(!HistoryTestHelper._nodes[uriFromIndex(2)], "Item RIP");
 
     // --------- delete multiple items
 
     let item1 = gPanelView._set.getItemsByUrl(uriFromIndex(0))[0];
     let item2 = gPanelView._set.getItemsByUrl(uriFromIndex(5))[0];
     let item3 = gPanelView._set.getItemsByUrl(uriFromIndex(12))[0];
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
     sendContextMenuClickToElement(window, item1, 10, 10);
     sendContextMenuClickToElement(window, item2, 10, 10);
     sendContextMenuClickToElement(window, item3, 10, 10);
     yield promise;
 
     ok(!deleteButton.hidden, "Delete button is visible.");
 
     let promise = waitForCondition(() => !restoreButton.hidden);
@@ -541,18 +541,18 @@ gTests.push({
     let startItem3 = gStartView._set.getItemsByUrl(uriFromIndex(12))[0];
 
     ok(!restoreButton.hidden, "Restore button is visible.");
     ok(!item1 && !item2 && !item3, "Items are not in grid");
     ok(startItem1 && startItem2 && startItem3, "Items are still in start grid");
     ok(HistoryTestHelper._nodes[uriFromIndex(0)] && HistoryTestHelper._nodes[uriFromIndex(5)] && HistoryTestHelper._nodes[uriFromIndex(12)],
       "Items not deleted yet");
 
-    let promise = waitForEvent(Elements.appbar, "transitionend", null, Elements.appbar);
-    Elements.appbar.dismiss();
+    let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
+    Elements.contextappbar.dismiss();
     yield promise;
 
     item1 = gPanelView._set.getItemsByUrl(uriFromIndex(0))[0];
     item2 = gPanelView._set.getItemsByUrl(uriFromIndex(5))[0];
     item3 = gPanelView._set.getItemsByUrl(uriFromIndex(12))[0];
     let startItem1 = gStartView._set.getItemsByUrl(uriFromIndex(0))[0];
     let startItem2 = gStartView._set.getItemsByUrl(uriFromIndex(5))[0];
     let startItem3 = gStartView._set.getItemsByUrl(uriFromIndex(12))[0];
--- a/browser/metro/base/tests/mochitest/browser_selection_basic.html
+++ b/browser/metro/base/tests/mochitest/browser_selection_basic.html
@@ -1,17 +1,14 @@
 <!DOCTYPE html>
 <html>
   <head>
-    <style>
-      #text { position: absolute; left: 1em; bottom: 1em; }
-    </style>
   </head>
 <body>
-<div style="margin: 0; padding: 0; max-width:500px;">
+<div style="margin: 0; padding: 0; max-width:31.25em; font-size: 95%;">
 There was nothing so VERY remarkable in that; nor did Alice think it so VERY much out of
 the way to hear the Rabbit say to itself, `Oh dear! Oh dear! I shall be late!' (when she
 thought it over afterwards, it occurred to her that she ought to have wondered at this,
 but at the time it all seemed quite natural); but when the Rabbit actually TOOK A WATCH
 OUT OF ITS WAISTCOAT- POCKET, and looked at it, and then hurried on, Alice started to her
 feet, for it flashed across her mind that she had never before seen a rabbit with either a
 waistcoat-pocket, or a watch to take out of it, and burning with curiosity, she ran across
 the field after it, and fortunately was just in time to see it pop down a large
@@ -56,11 +53,47 @@ found herself falling down a very deep w
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
 <br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
 </div>
 </body>
 </html>
--- a/browser/metro/base/tests/mochitest/browser_selection_frame_content.html
+++ b/browser/metro/base/tests/mochitest/browser_selection_frame_content.html
@@ -1,15 +1,15 @@
 <!DOCTYPE html>
 <html>
   <head>
   </head>
 <body>
 <div>
-<iframe id="frame1" width="800" height="600" src="res/textblock01.html"></iframe>
+<iframe id="frame1" style="width:50em; font-size: 95%;" height="600"  src="res/textblock01.html"></iframe>
 <br />
 <br />
 Hello there. <a id="rlink1" href="#hello">Hi!</a>
 <br />
 <br />
 <br />
 <br />
 <br />
--- a/browser/metro/base/tests/mochitest/browser_selection_frame_content.js
+++ b/browser/metro/base/tests/mochitest/browser_selection_frame_content.js
@@ -50,17 +50,17 @@ gTests.push({
 
 gTests.push({
   desc: "iframe basic selection",
   setUp: setUpAndTearDown,
   tearDown: setUpAndTearDown,
   run: function test() {
     gFrame.focus();
 
-    sendContextMenuClick(130, 95);
+    sendContextMenuClick(165, 35);
 
     yield waitForCondition(function () {
         return SelectionHelperUI.isSelectionUIVisible;
       }, kCommonWaitMs, kCommonPollMs);
 
     // active state
     is(SelectionHelperUI.isActive, true, "selection active");
     // check text selection
@@ -83,30 +83,30 @@ gTests.push({
 
     // active state
     is(SelectionHelperUI.isActive, true, "selection active");
     is(getTrimmedSelection(gFrame).toString(), "Alice", "selection test");
 
     let ypos = SelectionHelperUI.endMark.yPos + kMarkerOffsetY;
 
     let touchdrag = new TouchDragAndHold();
-    yield touchdrag.start(gWindow, SelectionHelperUI.endMark.xPos, ypos, 600, ypos);
+    yield touchdrag.start(gWindow, SelectionHelperUI.endMark.xPos, ypos, 640, ypos);
     touchdrag.end();
 
     yield waitForCondition(function () {
         return !SelectionHelperUI.hasActiveDrag;
       }, kCommonWaitMs, kCommonPollMs);
     yield SelectionHelperUI.pingSelectionHandler();
 
     is(SelectionHelperUI.isActive, true, "selection active");
     is(getTrimmedSelection(gFrame).toString(), "Alice was beginning to get very tired of sitting by her sister on the bank",
        "selection test");
 
     touchdrag = new TouchDragAndHold();
-    yield touchdrag.start(gWindow, SelectionHelperUI.endMark.xPos, ypos, 300, ypos);
+    yield touchdrag.start(gWindow, SelectionHelperUI.endMark.xPos, ypos, 320, ypos);
     touchdrag.end();
 
     yield waitForCondition(function () {
         return !SelectionHelperUI.hasActiveDrag;
       }, kCommonWaitMs, kCommonPollMs);
     yield SelectionHelperUI.pingSelectionHandler();
 
     is(SelectionHelperUI.isActive, true, "selection active");
@@ -119,17 +119,17 @@ gTests.push({
   setUp: setUpAndTearDown,
   run: function test() {
     gFrame.focus();
 
     let scrollPromise = waitForEvent(gFrame.contentDocument.defaultView, "scroll");
     gFrame.contentDocument.defaultView.scrollBy(0, 200);
     yield scrollPromise;
 
-    sendContextMenuClick(527, 188);
+    sendContextMenuClick(30, 240);
 
     yield waitForCondition(function () {
         return SelectionHelperUI.isSelectionUIVisible;
       }, kCommonWaitMs, kCommonPollMs);
 
     is(SelectionHelperUI.isActive, true, "selection active");
     is(getTrimmedSelection(gFrame).toString(), "started", "selection test");
 
@@ -181,17 +181,17 @@ gTests.push({
     gWindow.scrollBy(0, 200);
     yield scrollPromise;
 
     scrollPromise = waitForEvent(gFrame.contentDocument.defaultView, "scroll");
     gFrame.contentDocument.defaultView.scrollBy(0, 200);
     yield scrollPromise;
 
     InputSourceHelper.isPrecise = false;
-    sendContextMenuClick(114, 91);
+    sendContextMenuClick(114, 130);
 
     yield waitForCondition(function () {
         return SelectionHelperUI.isSelectionUIVisible;
       }, kCommonWaitMs, kCommonPollMs);
 
     is(SelectionHelperUI.isActive, true, "selection active");
     is(getTrimmedSelection(gFrame).toString(), "moment", "selection test");
   },
--- a/browser/metro/base/tests/mochitest/browser_selection_frame_inputs.html
+++ b/browser/metro/base/tests/mochitest/browser_selection_frame_inputs.html
@@ -1,15 +1,15 @@
 <!DOCTYPE html>
 <html>
 <head>
 <style>
 </style>
 </head>
-<body style="margin: 5px 5px 5px 85px;">
+<body style="margin: 5px 5px 5px 85px; font-size: 95%">
 <br />
 <br />
 <br />
 <br />
 <br />
 <br />
 <br />
 <br />
--- a/browser/metro/base/tests/mochitest/browser_selection_frame_inputs.js
+++ b/browser/metro/base/tests/mochitest/browser_selection_frame_inputs.js
@@ -60,17 +60,17 @@ gTests.push({
   desc: "basic selection",
   setUp: setUpAndTearDown,
   tearDown: setUpAndTearDown,
   run: function test() {
     gInput.focus();
     gInput.selectionStart = gInput.selectionEnd = 0;
 
     let promise = waitForEvent(document, "popupshown");
-    sendContextMenuClick(232, 583);
+    sendContextMenuClickToElement(gWindow, gFrame, 135, 10);
     yield promise;
 
     checkContextUIMenuItemVisibility(["context-select",
                                       "context-select-all"]);
 
     let menuItem = document.getElementById("context-select");
     ok(menuItem, "menu item exists");
     ok(!menuItem.hidden, "menu item visible");
@@ -79,31 +79,32 @@ gTests.push({
     yield popupPromise;
 
     yield waitForCondition(function () {
         return SelectionHelperUI.isSelectionUIVisible;
       }, kCommonWaitMs, kCommonPollMs);
 
     is(getTrimmedSelection(gInput).toString(), "straight", "selection test");
 
-    checkMonoclePositionRange("start", 210, 220, 600, 605);
-    checkMonoclePositionRange("end", 250, 260, 600, 605);
+    let rect = gFrame.getBoundingClientRect();
+    checkMonoclePositionRange("start", rect.left + 125, rect.left + 135, rect.top + 20, rect.top + 30);
+    checkMonoclePositionRange("end", rect.left + 165, rect.left + 175, rect.top + 20, rect.top + 30);
   },
 });
 
 gTests.push({
   desc: "drag selection",
   setUp: setUpAndTearDown,
   tearDown: setUpAndTearDown,
   run: function test() {
     gInput.focus();
     gInput.selectionStart = gInput.selectionEnd = 0;
 
     let promise = waitForEvent(document, "popupshown");
-    sendContextMenuClick(232, 583);
+    sendContextMenuClickToElement(gWindow, gFrame, 135, 10);
     yield promise;
 
     checkContextUIMenuItemVisibility(["context-select",
                                       "context-select-all"]);
 
     let menuItem = document.getElementById("context-select");
     ok(menuItem, "menu item exists");
     ok(!menuItem.hidden, "menu item visible");
--- a/browser/metro/base/tests/mochitest/browser_selection_frame_textarea.html
+++ b/browser/metro/base/tests/mochitest/browser_selection_frame_textarea.html
@@ -1,15 +1,15 @@
 <!DOCTYPE html>
 <html>
 <head>
 <style>
 </style>
 </head>
-<body style="margin: 5px 5px 5px 85px;">
+<body style="margin: 5px 5px 5px 85px; font-size: 95%">
 <br />
 <br />
 <br />
 <br />
 <br />
 <br />
 <br />
 <br />
--- a/browser/metro/base/tests/mochitest/browser_selection_frame_textarea.js
+++ b/browser/metro/base/tests/mochitest/browser_selection_frame_textarea.js
@@ -59,17 +59,17 @@ gTests.push({
   desc: "basic selection",
   setUp: setUpAndTearDown,
   tearDown: setUpAndTearDown,
   run: function test() {
     gTextArea.focus();
     gTextArea.selectionStart = gTextArea.selectionEnd = 0;
 
     let promise = waitForEvent(document, "popupshown");
-    sendContextMenuClick(275, 663);
+    sendContextMenuClickToElement(gWindow, gFrame, 195, 80);
     yield promise;
 
     checkContextUIMenuItemVisibility(["context-select",
                                       "context-select-all"]);
 
     let menuItem = document.getElementById("context-select");
     ok(menuItem, "menu item exists");
     ok(!menuItem.hidden, "menu item visible");
@@ -78,31 +78,31 @@ gTests.push({
     yield popupPromise;
 
     yield waitForCondition(function () {
         return SelectionHelperUI.isSelectionUIVisible;
       }, kCommonWaitMs, kCommonPollMs);
 
     is(getTrimmedSelection(gTextArea).toString(), "wondered", "selection test");
 
-    checkMonoclePositionRange("start", 260, 275, 675, 685);
-    checkMonoclePositionRange("end", 320, 335, 675, 685);
+    checkMonoclePositionRange("start", 260, 280, 675, 690);
+    checkMonoclePositionRange("end", 320, 340, 675, 690);
   },
 });
 
 gTests.push({
   desc: "drag selection",
   setUp: setUpAndTearDown,
   tearDown: setUpAndTearDown,
   run: function test() {
     gTextArea.focus();
     gTextArea.selectionStart = gTextArea.selectionEnd = 0;
 
     let promise = waitForEvent(document, "popupshown");
-    sendContextMenuClick(275, 663);
+    sendContextMenuClickToElement(gWindow, gFrame, 195, 80);
     yield promise;
 
     checkContextUIMenuItemVisibility(["context-select",
                                       "context-select-all"]);
 
     let menuItem = document.getElementById("context-select");
     ok(menuItem, "menu item exists");
     ok(!menuItem.hidden, "menu item visible");
@@ -173,17 +173,17 @@ gTests.push({
     gTextArea.focus();
     gTextArea.selectionStart = gTextArea.selectionEnd = 0;
 
     let scrollPromise = waitForEvent(gWindow, "scroll");
     gWindow.scrollBy(0, 200);
     yield scrollPromise;
 
     let promise = waitForEvent(document, "popupshown");
-    sendContextMenuClick(275, 463);
+    sendContextMenuClickToElement(gWindow, gFrame, 195, 80);
     yield promise;
 
     checkContextUIMenuItemVisibility(["context-select",
                                       "context-select-all"]);
 
     let menuItem = document.getElementById("context-select");
     ok(menuItem, "menu item exists");
     ok(!menuItem.hidden, "menu item visible");
--- a/browser/metro/base/tests/mochitest/browser_selection_inputs.js
+++ b/browser/metro/base/tests/mochitest/browser_selection_inputs.js
@@ -180,17 +180,17 @@ gTests.push({
     yield waitForMs(2000);
     touchdrag.end();
 
     is(getTrimmedSelection(gInput).toString(), "straight on like a tunnel for some way and then dipped suddenly down", "selection test");
 
     // left and up - selection should shrink
     let xpos = SelectionHelperUI.endMark.xPos;
     let ypos = SelectionHelperUI.endMark.yPos + 10;
-    yield touchdrag.start(gWindow, xpos, ypos, 105, 25);
+    yield touchdrag.start(gWindow, xpos, ypos, 110, 25);
     yield waitForCondition(function () {
       return getTrimmedSelection(gInput).toString() == 
         "straight on like a tunnel for";
     }, 6000, 2000);
     touchdrag.end();
   },
 });
 
--- a/browser/metro/base/tests/mochitest/head.js
+++ b/browser/metro/base/tests/mochitest/head.js
@@ -151,25 +151,33 @@ function clearSelection(aTarget) {
 
 /*=============================================================================
   Asynchronous Metro ui helpers
 =============================================================================*/
 
 function hideContextUI()
 {
   purgeEventQueue();
-  if (ContextUI.isVisible) {
-    let promise = waitForEvent(Elements.tray, "transitionend", null, Elements.tray);
-    if (ContextUI.dismiss())
-    {
-      info("ContextUI dismissed, waiting...");
-      return promise;
+
+  return Task.spawn(function() {
+    if (ContextUI.isExpanded) {
+      let promise = waitForEvent(Elements.tray, "transitionend", null, Elements.tray);
+      if (ContextUI.dismiss())
+      {
+        info("ContextUI dismissed, waiting...");
+        yield promise;
+      }
     }
-    return true;
-  }
+
+    if (Elements.contextappbar.isShowing) {
+      let promise = waitForEvent(Elements.contextappbar, "transitionend", null, Elements.contextappbar);
+      Elements.contextappbar.dismiss();
+      yield promise;
+    }
+  });
 }
 
 function showNavBar()
 {
   let promise = waitForEvent(Elements.tray, "transitionend");
   if (!ContextUI.isVisible) {
     ContextUI.displayNavbar();
     return promise;
@@ -248,19 +256,20 @@ function cleanUpOpenedTabs() {
  * @param aSubject the element that should receive the event
  * @param aEventName the event to wait for
  * @param aTimeoutMs the number of miliseconds to wait before giving up
  * @returns a Promise that resolves to the received event, or to an Error
  */
 function waitForEvent(aSubject, aEventName, aTimeoutMs, aTarget) {
   let eventDeferred = Promise.defer();
   let timeoutMs = aTimeoutMs || kDefaultWait;
+  let stack = new Error().stack;
   let timerID = setTimeout(function wfe_canceller() {
     aSubject.removeEventListener(aEventName, onEvent);
-    eventDeferred.reject( new Error(aEventName+" event timeout") );
+    eventDeferred.reject( new Error(aEventName+" event timeout at " + stack) );
   }, timeoutMs);
 
   function onEvent(aEvent) {
     if (aTarget && aTarget !== aEvent.target)
         return;
 
     // stop the timeout clock and resume
     clearTimeout(timerID);