mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Back out f1e0c231d7e4 (bug 1253604) for failures in at least browser_share.js
CLOSED TREE
This commit is contained in:
parent
9c0985024d
commit
c25f3b8001
@ -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);
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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]
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -1,9 +1,16 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script>
|
||||
addEventListener("OpenGraphData", function(e) {
|
||||
// frame scripts handle test data
|
||||
// share windows self-close
|
||||
history.back(); // bug 1042991, ensure history is available
|
||||
window.close();
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body onload="document.getElementById('testclose').focus()">
|
||||
<body>
|
||||
<p>This is a test social share window.</p>
|
||||
<input id="testclose"/>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user