From a3cd3904aee261eb1c687552999edc640ed40431 Mon Sep 17 00:00:00 2001 From: Tracy Walker Date: Wed, 20 Jan 2016 13:34:07 -0600 Subject: [PATCH] Bug 1240750 - Put add button in ContentTask and modernize the rest of the test case and remove relevant skip-if in layout/base/tests/browser.ini. r=mconley --- layout/base/tests/browser.ini | 1 - layout/base/tests/browser_bug617076.js | 75 +++++++++++--------------- 2 files changed, 30 insertions(+), 46 deletions(-) diff --git a/layout/base/tests/browser.ini b/layout/base/tests/browser.ini index 552180ff587..54b78b92fd2 100644 --- a/layout/base/tests/browser.ini +++ b/layout/base/tests/browser.ini @@ -1,7 +1,6 @@ [DEFAULT] [browser_bug617076.js] -skip-if = e10s # Bug ?????? - test touches content (TypeError: doc.documentElement is null) [browser_disableDialogs_onbeforeunload.js] [browser_onbeforeunload_only_after_interaction.js] [browser_onbeforeunload_only_after_interaction_in_frame.js] diff --git a/layout/base/tests/browser_bug617076.js b/layout/base/tests/browser_bug617076.js index ee8e1da6d45..d4e55f9b8e1 100644 --- a/layout/base/tests/browser_bug617076.js +++ b/layout/base/tests/browser_bug617076.js @@ -1,10 +1,3 @@ -function test() -{ - waitForExplicitFinish(); - - test1(); -} - /** * 1. load about:addons in a new tab and select that tab * 2. insert a button with tooltiptext @@ -15,47 +8,39 @@ function test() * * the test succeeds if it doesn't trigger any assertions */ -function test1() { - let uri = "about:addons"; - let tab = gBrowser.addTab(); - tab.linkedBrowser.addEventListener("load", function(aEvent) { - tab.linkedBrowser.removeEventListener("load", arguments.callee, true); +add_task(function* test() { + // Open the test tab + let testTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:addons"); - let doc = gBrowser.contentDocument; - var e = doc.createElement("button"); - e.setAttribute('label', "hello"); - e.setAttribute('tooltiptext', "world"); + // insert button into test page content + yield ContentTask.spawn(gBrowser.selectedBrowser, null, function* () { + let doc = content.document; + let e = doc.createElement("button"); + e.setAttribute("label", "hello"); + e.setAttribute("tooltiptext", "world"); + e.setAttribute("id", "test-button"); doc.documentElement.insertBefore(e, doc.documentElement.firstChild); + }); - let tab2 = gBrowser.addTab(); - gBrowser.selectedTab = tab2; + // open a second tab and select it + let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank", true); + gBrowser.selectedTab = tab2; - setTimeout(function() { - gBrowser.selectedTab = tab; + // Select the testTab then perform mouse events on inserted button + gBrowser.selectedTab = testTab; + let browser = gBrowser.selectedBrowser; + EventUtils.disableNonTestMouseEvents(true); + try { + yield BrowserTestUtils.synthesizeMouse("#test-button", 1, 1, { type: "mouseover" }, browser); + yield BrowserTestUtils.synthesizeMouse("#test-button", 2, 6, { type: "mousemove" }, browser); + yield BrowserTestUtils.synthesizeMouse("#test-button", 2, 4, { type: "mousemove" }, browser); + } finally { + EventUtils.disableNonTestMouseEvents(false); + } - let doc = gBrowser.contentDocument; - var win = gBrowser.contentWindow; - EventUtils.disableNonTestMouseEvents(true); - try { - EventUtils.synthesizeMouse(e, 1, 1, { type: "mouseover" }, win); - EventUtils.synthesizeMouse(e, 2, 6, { type: "mousemove" }, win); - EventUtils.synthesizeMouse(e, 2, 4, { type: "mousemove" }, win); - } finally { - EventUtils.disableNonTestMouseEvents(false); - } - - executeSoon(function() { - gBrowser.removeTab(tab, {animate: false}); - gBrowser.removeTab(tab2, {animate: false}); - ok(true, "pass if no assertions"); - - // done - executeSoon(finish); - }); - }, 0); - }, true); - - gBrowser.selectedTab = tab; - gBrowser.selectedBrowser.loadURI(uri); -} + // cleanup + yield BrowserTestUtils.removeTab(testTab); + yield BrowserTestUtils.removeTab(tab2); + ok(true, "pass if no assertions"); +});