From c25f3b8001219f6990eb4e157a3fd4113b8cdd5b Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Mon, 25 Apr 2016 20:41:11 -0700 Subject: [PATCH] Back out f1e0c231d7e4 (bug 1253604) for failures in at least browser_share.js CLOSED TREE --- browser/base/content/browser-social.js | 5 +- browser/base/content/social-content.js | 6 - browser/base/content/test/social/browser.ini | 1 + .../base/content/test/social/browser_share.js | 147 ++++-------------- browser/base/content/test/social/head.js | 9 +- browser/base/content/test/social/share.html | 11 +- 6 files changed, 47 insertions(+), 132 deletions(-) diff --git a/browser/base/content/browser-social.js b/browser/base/content/browser-social.js index 5ee0951cc82e..6c8f694d5425 100644 --- a/browser/base/content/browser-social.js +++ b/browser/base/content/browser-social.js @@ -489,6 +489,7 @@ SocialShare = { iframe.setAttribute("class", "social-share-frame"); iframe.setAttribute("context", "contentAreaContextMenu"); iframe.setAttribute("tooltip", "aHTMLTooltip"); + iframe.setAttribute("disablehistory", "true"); iframe.setAttribute("disableglobalhistory", "true"); iframe.setAttribute("flex", "1"); iframe.setAttribute("message", "true"); @@ -574,7 +575,6 @@ SocialShare = { onHidden: function() { (this._currentAnchor || this.anchor).removeAttribute("open"); this._currentAnchor = null; - this.iframe.docShellIsActive = false; this.iframe.removeEventListener("click", this._onclick, true); this.iframe.setAttribute("src", "data:text/plain;charset=utf8,"); // make sure that the frame is unloaded after it is hidden @@ -680,9 +680,6 @@ SocialShare = { // window.opener, some share endpoints rely on w.opener to know they // should close the window when done. iframe.contentWindow.opener = iframe.contentWindow; - // disable beforeunload dialogs - let mm = iframe.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader.messageManager; - mm.sendAsyncMessage("Social:DisableDialogs", {}); SocialShare._dynamicResizer.start(iframe.parentNode, iframe, size); diff --git a/browser/base/content/social-content.js b/browser/base/content/social-content.js index ffb375307a02..3a46286729e1 100644 --- a/browser/base/content/social-content.js +++ b/browser/base/content/social-content.js @@ -65,7 +65,6 @@ const SocialErrorListener = { addMessageListener("Social:ListenForEvents", this); addMessageListener("Social:SetDocumentTitle", this); addMessageListener("Social:SetErrorURL", this); - addMessageListener("Social:DisableDialogs", this); addMessageListener("Social:WaitForDocumentVisible", this); addMessageListener("WaitForDOMContentLoaded", this); let webProgress = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor) @@ -176,11 +175,6 @@ const SocialErrorListener = { sendAsyncMessage("Social:DocumentVisible"); }); break; - case "Social:DisableDialogs": - let windowUtils = content.QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIDOMWindowUtils); - windowUtils.disableDialogs(); - break; case "WaitForDOMContentLoaded": if (gDOMContentLoaded) { sendAsyncMessage("DOMContentLoaded"); diff --git a/browser/base/content/test/social/browser.ini b/browser/base/content/test/social/browser.ini index cfef6e879a11..ac98451490c3 100644 --- a/browser/base/content/test/social/browser.ini +++ b/browser/base/content/test/social/browser.ini @@ -30,6 +30,7 @@ support-files = [browser_addons.js] [browser_blocklist.js] [browser_share.js] +skip-if = true # bug 1115131 [browser_social_activation.js] [browser_social_chatwindow.js] [browser_social_chatwindow_resize.js] diff --git a/browser/base/content/test/social/browser_share.js b/browser/base/content/test/social/browser_share.js index e6ae748aa0d4..3e91d2b5d586 100644 --- a/browser/base/content/test/social/browser_share.js +++ b/browser/base/content/test/social/browser_share.js @@ -21,6 +21,18 @@ function sendActivationEvent(subframe) { EventUtils.synthesizeMouseAtCenter(button, {}, doc.defaultView); } +function promiseShareFrameEvent(iframe, eventName) { + let deferred = Promise.defer(); + iframe.addEventListener(eventName, function load(event) { + info("page load is " + iframe.contentDocument.location.href); + if (iframe.contentDocument.location.href != "data:text/plain;charset=utf8,") { + iframe.removeEventListener(eventName, load, true); + deferred.resolve(event); + } + }, true); + return deferred.promise; +} + function test() { waitForExplicitFinish(); Services.prefs.setCharPref("social.shareDirectory", activationPage); @@ -29,16 +41,6 @@ function test() { addEventListener("OpenGraphData", function (aEvent) { sendAsyncMessage("sharedata", aEvent.detail); }, true, true); - /* bug 1042991, ensure history is available by calling history.back on close */ - addMessageListener("closeself", function(e) { - content.history.back(); - content.close(); - }, true); - /* if text is entered into field, onbeforeunload will cause a modal dialog - unless dialogs have been disabled for the iframe. */ - content.onbeforeunload = function(e) { - return 'FAIL.'; - }; }.toString() + ")();"; let mm = getGroupMessageManager("social"); mm.loadFrameScript(frameScript, true); @@ -186,48 +188,28 @@ var tests = { let testIndex = 0; let testData = corpus[testIndex++]; - // initialize the button into the navbar - CustomizableUI.addWidgetToArea("social-share-button", CustomizableUI.AREA_NAVBAR); - // ensure correct state - SocialUI.onCustomizeEnd(window); - let mm = getGroupMessageManager("social"); mm.addMessageListener("sharedata", function handler(msg) { gBrowser.removeTab(testTab); hasoptions(testData.options, JSON.parse(msg.data)); testData = corpus[testIndex++]; - BrowserTestUtils.waitForCondition(() => { return SocialShare.currentShare == null; },"share panel closed").then(() => { - if (testData) { - runOneTest(); - } else { - mm.removeMessageListener("sharedata", handler); - SocialService.disableProvider(manifest.origin, next); - } - }); - SocialShare.iframe.messageManager.sendAsyncMessage("closeself", {}); + if (testData) { + executeSoon(runOneTest); + } else { + mm.removeMessageListener("sharedata", handler); + SocialService.disableProvider(manifest.origin, next); + } }); function runOneTest() { addTab(testData.url, function(tab) { testTab = tab; - - let shareButton = SocialShare.shareButton; - // verify the attribute for proper css - ok(!shareButton.hasAttribute("disabled"), "share button is enabled"); - // button should be visible - is(shareButton.hidden, false, "share button is visible"); - SocialShare.sharePage(manifest.origin); }); } executeSoon(runOneTest); }, testShareMicroformats: function(next) { - // initialize the button into the navbar - CustomizableUI.addWidgetToArea("social-share-button", CustomizableUI.AREA_NAVBAR); - // ensure correct state - SocialUI.onCustomizeEnd(window); - SocialService.addProvider(manifest, function(provider) { let target, testTab; @@ -279,25 +261,14 @@ var tests = { let mm = getGroupMessageManager("social"); mm.addMessageListener("sharedata", function handler(msg) { is(msg.data, expecting, "microformats data ok"); - BrowserTestUtils.waitForCondition(() => { return SocialShare.currentShare == null; }, - "share panel closed").then(() => { - gBrowser.removeTab(testTab); - mm.removeMessageListener("sharedata", handler); - SocialService.disableProvider(manifest.origin, next); - }); - SocialShare.iframe.messageManager.sendAsyncMessage("closeself", {}); + gBrowser.removeTab(testTab); + mm.removeMessageListener("sharedata", handler); + SocialService.disableProvider(manifest.origin, next); }); let url = "https://example.com/browser/browser/base/content/test/social/microformats.html" addTab(url, function(tab) { testTab = tab; - - let shareButton = SocialShare.shareButton; - // verify the attribute for proper css - ok(!shareButton.hasAttribute("disabled"), "share button is enabled"); - // button should be visible - is(shareButton.hidden, false, "share button is visible"); - let doc = tab.linkedBrowser.contentDocument; target = doc.getElementById("simple-hcard"); SocialShare.sharePage(manifest.origin, null, target); @@ -313,83 +284,31 @@ var tests = { SocialShare._createFrame(); let iframe = SocialShare.iframe; - // initialize the button into the navbar - CustomizableUI.addWidgetToArea("social-share-button", CustomizableUI.AREA_NAVBAR); - // ensure correct state - SocialUI.onCustomizeEnd(window); - - ensureEventFired(iframe, "load").then(() => { + promiseShareFrameEvent(iframe, "load").then(() => { let subframe = iframe.contentDocument.getElementById("activation-frame"); - ensureFrameLoaded(subframe, activationPage).then(() => { + waitForCondition(() => { + // sometimes the iframe is ready before the panel is open, we need to + // wait for both conditions + return SocialShare.panel.state == "open" + && subframe.contentDocument + && subframe.contentDocument.readyState == "complete"; + }, () => { is(subframe.contentDocument.location.href, activationPage, "activation page loaded"); promiseObserverNotified("social:provider-enabled").then(() => { let mm = getGroupMessageManager("social"); mm.addMessageListener("sharedata", function handler(msg) { ok(true, "share completed"); - - BrowserTestUtils.waitForCondition(() => { return SocialShare.currentShare == null; }, - "share panel closed").then(() => { - ensureBrowserTabClosed(testTab).then(() => { - mm.removeMessageListener("sharedata", handler); - SocialService.uninstallProvider(manifest.origin, next); - }); - }); - SocialShare.iframe.messageManager.sendAsyncMessage("closeself", {}); + gBrowser.removeTab(testTab); + mm.removeMessageListener("sharedata", handler); + SocialService.uninstallProvider(manifest.origin, next); }); }); sendActivationEvent(subframe); - }); + }, "share panel did not open and load share page"); }); addTab(activationPage, function(tab) { - let shareButton = SocialShare.shareButton; - // verify the attribute for proper css - ok(!shareButton.hasAttribute("disabled"), "share button is enabled"); - // button should be visible - is(shareButton.hidden, false, "share button is visible"); - testTab = tab; SocialShare.sharePage(); }); - }, - testSharePanelDialog: function(next) { - let testTab; - // initialize the button into the navbar - CustomizableUI.addWidgetToArea("social-share-button", CustomizableUI.AREA_NAVBAR); - // ensure correct state - SocialUI.onCustomizeEnd(window); - SocialShare._createFrame(); - - SocialService.addProvider(manifest, () => { - addTab(activationPage, (tab) => { - ensureEventFired(SocialShare.iframe, "load").then(() => { - // send keys to the input field. An unexpected failure will happen - // if the onbeforeunload handler is fired. - EventUtils.sendKey("f"); - EventUtils.sendKey("a"); - EventUtils.sendKey("i"); - EventUtils.sendKey("l"); - - SocialShare.panel.addEventListener("popuphidden", function hidden(evt) { - SocialShare.panel.removeEventListener("popuphidden", hidden); - let topwin = Services.wm.getMostRecentWindow(null); - is(topwin, window, "no dialog is open"); - - ensureBrowserTabClosed(testTab).then(() => { - SocialService.disableProvider(manifest.origin, next); - }); - }); - SocialShare.iframe.messageManager.sendAsyncMessage("closeself", {}); - }); - - let shareButton = SocialShare.shareButton; - // verify the attribute for proper css - ok(!shareButton.hasAttribute("disabled"), "share button is enabled"); - // button should be visible - is(shareButton.hidden, false, "share button is visible"); - - testTab = tab; - SocialShare.sharePage(); - }); - }); } } diff --git a/browser/base/content/test/social/head.js b/browser/base/content/test/social/head.js index e6b7fd8e358a..d792db25aeb1 100644 --- a/browser/base/content/test/social/head.js +++ b/browser/base/content/test/social/head.js @@ -415,19 +415,16 @@ function loadIntoTab(tab, url, callback) { function ensureBrowserTabClosed(tab) { let promise = ensureEventFired(gBrowser.tabContainer, "TabClose"); - gBrowser.removeTab(tab); + gBrowser.removeTab(tab, {skipPermitUnload: true}); return promise; } -function ensureFrameLoaded(frame, uri) { +function ensureFrameLoaded(frame) { let deferred = Promise.defer(); - if (frame.contentDocument && frame.contentDocument.readyState == "complete" && - (!uri || frame.contentDocument.location.href == uri)) { + if (frame.contentDocument && frame.contentDocument.readyState == "complete") { deferred.resolve(); } else { frame.addEventListener("load", function handler() { - if (uri && frame.contentDocument.location.href != uri) - return; frame.removeEventListener("load", handler, true); deferred.resolve() }, true); diff --git a/browser/base/content/test/social/share.html b/browser/base/content/test/social/share.html index 55cba9844810..a354bd473c31 100644 --- a/browser/base/content/test/social/share.html +++ b/browser/base/content/test/social/share.html @@ -1,9 +1,16 @@ + - +

This is a test social share window.

-