mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 787511 - rename SocialProvider._getWorkerPort to getWorkerPort, remove SocialProvider.port. r=jaws
This commit is contained in:
parent
f99c450143
commit
16df89bdb1
@ -326,7 +326,7 @@ let SocialShareButton = {
|
|||||||
// whenever we notice the provider has changed - but the concept of
|
// whenever we notice the provider has changed - but the concept of
|
||||||
// "provider changed" will only exist once bug 774520 lands.
|
// "provider changed" will only exist once bug 774520 lands.
|
||||||
// get the recommend-prompt info.
|
// get the recommend-prompt info.
|
||||||
let port = Social.provider._getWorkerPort();
|
let port = Social.provider.getWorkerPort();
|
||||||
if (port) {
|
if (port) {
|
||||||
port.onmessage = function(evt) {
|
port.onmessage = function(evt) {
|
||||||
if (evt.data.topic == "social.user-recommend-prompt-response") {
|
if (evt.data.topic == "social.user-recommend-prompt-response") {
|
||||||
|
@ -24,7 +24,7 @@ function test() {
|
|||||||
var tests = {
|
var tests = {
|
||||||
testOpenCloseChat: function(next) {
|
testOpenCloseChat: function(next) {
|
||||||
let chats = document.getElementById("pinnedchats");
|
let chats = document.getElementById("pinnedchats");
|
||||||
let port = Social.provider.port;
|
let port = Social.provider.getWorkerPort();
|
||||||
ok(port, "provider has a port");
|
ok(port, "provider has a port");
|
||||||
port.onmessage = function (e) {
|
port.onmessage = function (e) {
|
||||||
let topic = e.data.topic;
|
let topic = e.data.topic;
|
||||||
@ -43,6 +43,7 @@ var tests = {
|
|||||||
iframe.addEventListener("unload", function chatUnload() {
|
iframe.addEventListener("unload", function chatUnload() {
|
||||||
iframe.removeEventListener("unload", chatUnload, true);
|
iframe.removeEventListener("unload", chatUnload, true);
|
||||||
ok(true, "got chatbox unload on close");
|
ok(true, "got chatbox unload on close");
|
||||||
|
port.close();
|
||||||
next();
|
next();
|
||||||
}, true);
|
}, true);
|
||||||
chats.selectedChat.close();
|
chats.selectedChat.close();
|
||||||
@ -60,8 +61,9 @@ var tests = {
|
|||||||
testManyChats: function(next) {
|
testManyChats: function(next) {
|
||||||
// open enough chats to overflow the window, then check
|
// open enough chats to overflow the window, then check
|
||||||
// if the menupopup is visible
|
// if the menupopup is visible
|
||||||
let port = Social.provider.port;
|
let port = Social.provider.getWorkerPort();
|
||||||
ok(port, "provider has a port");
|
ok(port, "provider has a port");
|
||||||
|
port.postMessage({topic: "test-init"});
|
||||||
let width = document.documentElement.boxObject.width;
|
let width = document.documentElement.boxObject.width;
|
||||||
let numToOpen = (width / 200) + 1;
|
let numToOpen = (width / 200) + 1;
|
||||||
port.onmessage = function (e) {
|
port.onmessage = function (e) {
|
||||||
@ -81,6 +83,7 @@ var tests = {
|
|||||||
chats.selectedChat.close();
|
chats.selectedChat.close();
|
||||||
}
|
}
|
||||||
ok(!chats.selectedChat, "chats are all closed");
|
ok(!chats.selectedChat, "chats are all closed");
|
||||||
|
port.close();
|
||||||
next();
|
next();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -92,8 +95,9 @@ var tests = {
|
|||||||
},
|
},
|
||||||
testWorkerChatWindow: function(next) {
|
testWorkerChatWindow: function(next) {
|
||||||
const chatUrl = "https://example.com/browser/browser/base/content/test/social_chat.html";
|
const chatUrl = "https://example.com/browser/browser/base/content/test/social_chat.html";
|
||||||
let port = Social.provider.port;
|
let port = Social.provider.getWorkerPort();
|
||||||
ok(port, "provider has a port");
|
ok(port, "provider has a port");
|
||||||
|
port.postMessage({topic: "test-init"});
|
||||||
port.onmessage = function (e) {
|
port.onmessage = function (e) {
|
||||||
let topic = e.data.topic;
|
let topic = e.data.topic;
|
||||||
switch (topic) {
|
switch (topic) {
|
||||||
@ -104,6 +108,7 @@ var tests = {
|
|||||||
chats.selectedChat.close();
|
chats.selectedChat.close();
|
||||||
}
|
}
|
||||||
ok(!chats.selectedChat, "chats are all closed");
|
ok(!chats.selectedChat, "chats are all closed");
|
||||||
|
port.close();
|
||||||
ensureSocialUrlNotRemembered(chatUrl);
|
ensureSocialUrlNotRemembered(chatUrl);
|
||||||
next();
|
next();
|
||||||
break;
|
break;
|
||||||
|
@ -20,7 +20,7 @@ function test() {
|
|||||||
var tests = {
|
var tests = {
|
||||||
testOpenCloseFlyout: function(next) {
|
testOpenCloseFlyout: function(next) {
|
||||||
let panel = document.getElementById("social-flyout-panel");
|
let panel = document.getElementById("social-flyout-panel");
|
||||||
let port = Social.provider.port;
|
let port = Social.provider.getWorkerPort();
|
||||||
ok(port, "provider has a port");
|
ok(port, "provider has a port");
|
||||||
port.onmessage = function (e) {
|
port.onmessage = function (e) {
|
||||||
let topic = e.data.topic;
|
let topic = e.data.topic;
|
||||||
@ -31,6 +31,7 @@ var tests = {
|
|||||||
case "got-flyout-visibility":
|
case "got-flyout-visibility":
|
||||||
if (e.data.result == "hidden") {
|
if (e.data.result == "hidden") {
|
||||||
ok(true, "flyout visibility is 'hidden'");
|
ok(true, "flyout visibility is 'hidden'");
|
||||||
|
port.close();
|
||||||
next();
|
next();
|
||||||
} else if (e.data.result == "shown") {
|
} else if (e.data.result == "shown") {
|
||||||
ok(true, "flyout visibility is 'shown");
|
ok(true, "flyout visibility is 'shown");
|
||||||
|
@ -19,41 +19,46 @@ function test() {
|
|||||||
|
|
||||||
var tests = {
|
var tests = {
|
||||||
testSidebarMessage: function(next) {
|
testSidebarMessage: function(next) {
|
||||||
let port = Social.provider.port;
|
let port = Social.provider.getWorkerPort();
|
||||||
ok(port, "provider has a port");
|
ok(port, "provider has a port");
|
||||||
port.postMessage({topic: "test-init"});
|
port.postMessage({topic: "test-init"});
|
||||||
Social.provider.port.onmessage = function (e) {
|
port.onmessage = function (e) {
|
||||||
let topic = e.data.topic;
|
let topic = e.data.topic;
|
||||||
switch (topic) {
|
switch (topic) {
|
||||||
case "got-sidebar-message":
|
case "got-sidebar-message":
|
||||||
// The sidebar message will always come first, since it loads by default
|
// The sidebar message will always come first, since it loads by default
|
||||||
ok(true, "got sidebar message");
|
ok(true, "got sidebar message");
|
||||||
|
port.close();
|
||||||
next();
|
next();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
testIsVisible: function(next) {
|
testIsVisible: function(next) {
|
||||||
let port = Social.provider.port;
|
let port = Social.provider.getWorkerPort();
|
||||||
|
port.postMessage({topic: "test-init"});
|
||||||
port.onmessage = function (e) {
|
port.onmessage = function (e) {
|
||||||
let topic = e.data.topic;
|
let topic = e.data.topic;
|
||||||
switch (topic) {
|
switch (topic) {
|
||||||
case "got-isVisible-response":
|
case "got-isVisible-response":
|
||||||
is(e.data.result, true, "Sidebar should be visible by default");
|
is(e.data.result, true, "Sidebar should be visible by default");
|
||||||
Social.toggleSidebar();
|
Social.toggleSidebar();
|
||||||
|
port.close();
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
port.postMessage({topic: "test-isVisible"});
|
port.postMessage({topic: "test-isVisible"});
|
||||||
},
|
},
|
||||||
testIsNotVisible: function(next) {
|
testIsNotVisible: function(next) {
|
||||||
let port = Social.provider.port;
|
let port = Social.provider.getWorkerPort();
|
||||||
|
port.postMessage({topic: "test-init"});
|
||||||
port.onmessage = function (e) {
|
port.onmessage = function (e) {
|
||||||
let topic = e.data.topic;
|
let topic = e.data.topic;
|
||||||
switch (topic) {
|
switch (topic) {
|
||||||
case "got-isVisible-response":
|
case "got-isVisible-response":
|
||||||
is(e.data.result, false, "Sidebar should be hidden");
|
is(e.data.result, false, "Sidebar should be hidden");
|
||||||
Services.prefs.clearUserPref("social.sidebar.open");
|
Services.prefs.clearUserPref("social.sidebar.open");
|
||||||
|
port.close();
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -35,7 +35,7 @@ var tests = {
|
|||||||
EventUtils.synthesizeMouseAtCenter(statusIcons.firstChild, {});
|
EventUtils.synthesizeMouseAtCenter(statusIcons.firstChild, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
let port = Social.provider.port;
|
let port = Social.provider.getWorkerPort();
|
||||||
ok(port, "provider has a port");
|
ok(port, "provider has a port");
|
||||||
port.onmessage = function (e) {
|
port.onmessage = function (e) {
|
||||||
let topic = e.data.topic;
|
let topic = e.data.topic;
|
||||||
@ -52,6 +52,7 @@ var tests = {
|
|||||||
panel.hidePopup();
|
panel.hidePopup();
|
||||||
} else if (e.data.result == "hidden") {
|
} else if (e.data.result == "hidden") {
|
||||||
ok(true, "panel hidden");
|
ok(true, "panel hidden");
|
||||||
|
port.close();
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -40,7 +40,9 @@ function tabLoaded() {
|
|||||||
function testInitial(finishcb) {
|
function testInitial(finishcb) {
|
||||||
ok(Social.provider, "Social provider is active");
|
ok(Social.provider, "Social provider is active");
|
||||||
ok(Social.provider.enabled, "Social provider is enabled");
|
ok(Social.provider.enabled, "Social provider is enabled");
|
||||||
ok(Social.provider.port, "Social provider has a port to its FrameWorker");
|
let port = Social.provider.getWorkerPort();
|
||||||
|
ok(port, "Social provider has a port to its FrameWorker");
|
||||||
|
port.close();
|
||||||
|
|
||||||
let {shareButton, sharePopup} = SocialShareButton;
|
let {shareButton, sharePopup} = SocialShareButton;
|
||||||
ok(shareButton, "share button exists");
|
ok(shareButton, "share button exists");
|
||||||
|
@ -35,7 +35,7 @@ let Social = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
get uiVisible() {
|
get uiVisible() {
|
||||||
return this.provider && this.provider.enabled && this.provider.port;
|
return this.provider && this.provider.enabled;
|
||||||
},
|
},
|
||||||
|
|
||||||
set enabled(val) {
|
set enabled(val) {
|
||||||
@ -62,13 +62,6 @@ let Social = {
|
|||||||
Services.prefs.setBoolPref("social.sidebar.open", !prefValue);
|
Services.prefs.setBoolPref("social.sidebar.open", !prefValue);
|
||||||
},
|
},
|
||||||
|
|
||||||
sendWorkerMessage: function Social_sendWorkerMessage(message) {
|
|
||||||
// Responses aren't handled yet because there is no actions to perform
|
|
||||||
// based on the response from the provider at this point.
|
|
||||||
if (this.provider && this.provider.port)
|
|
||||||
this.provider.port.postMessage(message);
|
|
||||||
},
|
|
||||||
|
|
||||||
// Sharing functionality
|
// Sharing functionality
|
||||||
_getShareablePageUrl: function Social_getShareablePageUrl(aURI) {
|
_getShareablePageUrl: function Social_getShareablePageUrl(aURI) {
|
||||||
let uri = aURI.clone();
|
let uri = aURI.clone();
|
||||||
@ -85,21 +78,43 @@ let Social = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
sharePage: function Social_sharePage(aURI) {
|
sharePage: function Social_sharePage(aURI) {
|
||||||
|
// this should not be called if this.provider or the port is null
|
||||||
|
if (!this.provider) {
|
||||||
|
Cu.reportError("Can't share a page when no provider is current");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let port = this.provider.getWorkerPort();
|
||||||
|
if (!port) {
|
||||||
|
Cu.reportError("Can't share page as no provider port is available");
|
||||||
|
return;
|
||||||
|
}
|
||||||
let url = this._getShareablePageUrl(aURI);
|
let url = this._getShareablePageUrl(aURI);
|
||||||
this._sharedUrls[url] = true;
|
this._sharedUrls[url] = true;
|
||||||
this.sendWorkerMessage({
|
port.postMessage({
|
||||||
topic: "social.user-recommend",
|
topic: "social.user-recommend",
|
||||||
data: { url: url }
|
data: { url: url }
|
||||||
});
|
});
|
||||||
|
port.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
unsharePage: function Social_unsharePage(aURI) {
|
unsharePage: function Social_unsharePage(aURI) {
|
||||||
|
// this should not be called if this.provider or the port is null
|
||||||
|
if (!this.provider) {
|
||||||
|
Cu.reportError("Can't unshare a page when no provider is current");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let port = this.provider.getWorkerPort();
|
||||||
|
if (!port) {
|
||||||
|
Cu.reportError("Can't unshare page as no provider port is available");
|
||||||
|
return;
|
||||||
|
}
|
||||||
let url = this._getShareablePageUrl(aURI);
|
let url = this._getShareablePageUrl(aURI);
|
||||||
delete this._sharedUrls[url];
|
delete this._sharedUrls[url];
|
||||||
this.sendWorkerMessage({
|
port.postMessage({
|
||||||
topic: "social.user-unrecommend",
|
topic: "social.user-unrecommend",
|
||||||
data: { url: url }
|
data: { url: url }
|
||||||
});
|
});
|
||||||
|
port.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
_sharedUrls: {}
|
_sharedUrls: {}
|
||||||
|
@ -75,7 +75,7 @@ function attachToWindow(provider, targetWindow) {
|
|||||||
throw new Error("MozSocialAPI: cannot attach " + origin + " to " + targetDocURI.spec);
|
throw new Error("MozSocialAPI: cannot attach " + origin + " to " + targetDocURI.spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
var port = provider._getWorkerPort(targetWindow);
|
var port = provider.getWorkerPort(targetWindow);
|
||||||
|
|
||||||
let mozSocialObj = {
|
let mozSocialObj = {
|
||||||
// Use a method for backwards compat with existing providers, but we
|
// Use a method for backwards compat with existing providers, but we
|
||||||
|
@ -191,10 +191,6 @@ SocialProvider.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Active port to the provider's FrameWorker. Null if the provider has no
|
|
||||||
// FrameWorker, or is disabled.
|
|
||||||
port: null,
|
|
||||||
|
|
||||||
// Reference to a workerAPI object for this provider. Null if the provider has
|
// Reference to a workerAPI object for this provider. Null if the provider has
|
||||||
// no FrameWorker, or is disabled.
|
// no FrameWorker, or is disabled.
|
||||||
workerAPI: null,
|
workerAPI: null,
|
||||||
@ -261,11 +257,9 @@ SocialProvider.prototype = {
|
|||||||
_activate: function _activate() {
|
_activate: function _activate() {
|
||||||
// Initialize the workerAPI and its port first, so that its initialization
|
// Initialize the workerAPI and its port first, so that its initialization
|
||||||
// occurs before any other messages are processed by other ports.
|
// occurs before any other messages are processed by other ports.
|
||||||
let workerAPIPort = this._getWorkerPort();
|
let workerAPIPort = this.getWorkerPort();
|
||||||
if (workerAPIPort)
|
if (workerAPIPort)
|
||||||
this.workerAPI = new WorkerAPI(this, workerAPIPort);
|
this.workerAPI = new WorkerAPI(this, workerAPIPort);
|
||||||
|
|
||||||
this.port = this._getWorkerPort();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_terminate: function _terminate() {
|
_terminate: function _terminate() {
|
||||||
@ -276,7 +270,9 @@ SocialProvider.prototype = {
|
|||||||
Cu.reportError("SocialProvider FrameWorker termination failed: " + e);
|
Cu.reportError("SocialProvider FrameWorker termination failed: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.port = null;
|
if (this.workerAPI) {
|
||||||
|
this.workerAPI.terminate();
|
||||||
|
}
|
||||||
this.workerAPI = null;
|
this.workerAPI = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -288,14 +284,9 @@ SocialProvider.prototype = {
|
|||||||
*
|
*
|
||||||
* @param {DOMWindow} window (optional)
|
* @param {DOMWindow} window (optional)
|
||||||
*/
|
*/
|
||||||
_getWorkerPort: function _getWorkerPort(window) {
|
getWorkerPort: function getWorkerPort(window) {
|
||||||
if (!this.workerURL || !this.enabled)
|
if (!this.workerURL || !this.enabled)
|
||||||
return null;
|
return null;
|
||||||
try {
|
return getFrameWorkerHandle(this.workerURL, window).port;
|
||||||
return getFrameWorkerHandle(this.workerURL, window).port;
|
|
||||||
} catch (ex) {
|
|
||||||
Cu.reportError("SocialProvider: retrieving worker port failed:" + ex);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,10 @@ function WorkerAPI(provider, port) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WorkerAPI.prototype = {
|
WorkerAPI.prototype = {
|
||||||
|
terminate: function terminate() {
|
||||||
|
this._port.close();
|
||||||
|
},
|
||||||
|
|
||||||
_handleMessage: function _handleMessage(event) {
|
_handleMessage: function _handleMessage(event) {
|
||||||
let {topic, data} = event.data;
|
let {topic, data} = event.data;
|
||||||
let handler = this.handlers[topic];
|
let handler = this.handlers[topic];
|
||||||
|
@ -15,19 +15,24 @@ function test() {
|
|||||||
|
|
||||||
SocialService.addProvider(manifest, function (provider) {
|
SocialService.addProvider(manifest, function (provider) {
|
||||||
ok(provider.enabled, "provider is initially enabled");
|
ok(provider.enabled, "provider is initially enabled");
|
||||||
ok(provider.port, "should be able to get a port from enabled provider");
|
let port = provider.getWorkerPort();
|
||||||
|
ok(port, "should be able to get a port from enabled provider");
|
||||||
|
port.close();
|
||||||
ok(provider.workerAPI, "should be able to get a workerAPI from enabled provider");
|
ok(provider.workerAPI, "should be able to get a workerAPI from enabled provider");
|
||||||
|
|
||||||
provider.enabled = false;
|
provider.enabled = false;
|
||||||
|
|
||||||
ok(!provider.enabled, "provider is now disabled");
|
ok(!provider.enabled, "provider is now disabled");
|
||||||
ok(!provider.port, "shouldn't be able to get a port from disabled provider");
|
port = provider.getWorkerPort();
|
||||||
|
ok(!port, "shouldn't be able to get a port from disabled provider");
|
||||||
ok(!provider.workerAPI, "shouldn't be able to get a workerAPI from disabled provider");
|
ok(!provider.workerAPI, "shouldn't be able to get a workerAPI from disabled provider");
|
||||||
|
|
||||||
provider.enabled = true;
|
provider.enabled = true;
|
||||||
|
|
||||||
ok(provider.enabled, "provider is re-enabled");
|
ok(provider.enabled, "provider is re-enabled");
|
||||||
ok(provider.port, "should be able to get a port from re-enabled provider");
|
let port = provider.getWorkerPort();
|
||||||
|
ok(port, "should be able to get a port from re-enabled provider");
|
||||||
|
port.close();
|
||||||
ok(provider.workerAPI, "should be able to get a workerAPI from re-enabled provider");
|
ok(provider.workerAPI, "should be able to get a workerAPI from re-enabled provider");
|
||||||
|
|
||||||
SocialService.removeProvider(provider.origin, finish);
|
SocialService.removeProvider(provider.origin, finish);
|
||||||
|
@ -132,17 +132,19 @@ let tests = {
|
|||||||
}
|
}
|
||||||
Services.obs.addObserver(observer, "social-test:notification-alert", false);
|
Services.obs.addObserver(observer, "social-test:notification-alert", false);
|
||||||
|
|
||||||
provider.port.onmessage = function(e) {
|
let port = provider.getWorkerPort();
|
||||||
|
port.onmessage = function(e) {
|
||||||
if (e.data.topic == "test.done") {
|
if (e.data.topic == "test.done") {
|
||||||
ok(e.data.data, "check the test worked");
|
ok(e.data.data, "check the test worked");
|
||||||
ok(observer.observedData, "test observer fired");
|
ok(observer.observedData, "test observer fired");
|
||||||
is(observer.observedData.text, "test notification", "check the alert text is correct");
|
is(observer.observedData.text, "test notification", "check the alert text is correct");
|
||||||
is(observer.observedData.title, "Example Provider", "check the alert title is correct");
|
is(observer.observedData.title, "Example Provider", "check the alert title is correct");
|
||||||
is(observer.observedData.textClickable, true, "check the alert is clickable");
|
is(observer.observedData.textClickable, true, "check the alert is clickable");
|
||||||
|
port.close();
|
||||||
cbnext();
|
cbnext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
provider.port.postMessage({topic: "test.initialize"});
|
port.postMessage({topic: "test.initialize"});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -28,13 +28,14 @@ let tests = {
|
|||||||
ok(provider.workerAPI, "provider has a workerAPI");
|
ok(provider.workerAPI, "provider has a workerAPI");
|
||||||
is(provider.workerAPI.initialized, false, "workerAPI is not yet initialized");
|
is(provider.workerAPI.initialized, false, "workerAPI is not yet initialized");
|
||||||
|
|
||||||
let port = provider.port;
|
let port = provider.getWorkerPort();
|
||||||
ok(port, "should be able to get a port from the provider");
|
ok(port, "should be able to get a port from the provider");
|
||||||
|
|
||||||
port.onmessage = function onMessage(event) {
|
port.onmessage = function onMessage(event) {
|
||||||
let topic = event.data.topic;
|
let topic = event.data.topic;
|
||||||
if (topic == "test-initialization-complete") {
|
if (topic == "test-initialization-complete") {
|
||||||
is(provider.workerAPI.initialized, true, "workerAPI is now initialized");
|
is(provider.workerAPI.initialized, true, "workerAPI is now initialized");
|
||||||
|
port.close();
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,7 +61,9 @@ let tests = {
|
|||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
Services.obs.addObserver(ob, "social:profile-changed", false);
|
Services.obs.addObserver(ob, "social:profile-changed", false);
|
||||||
provider.port.postMessage({topic: "test-profile", data: expect});
|
let port = provider.getWorkerPort();
|
||||||
|
port.postMessage({topic: "test-profile", data: expect});
|
||||||
|
port.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
testAmbientNotification: function(next) {
|
testAmbientNotification: function(next) {
|
||||||
@ -76,7 +79,9 @@ let tests = {
|
|||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
Services.obs.addObserver(ob, "social:ambient-notification-changed", false);
|
Services.obs.addObserver(ob, "social:ambient-notification-changed", false);
|
||||||
provider.port.postMessage({topic: "test-ambient", data: expect});
|
let port = provider.getWorkerPort();
|
||||||
|
port.postMessage({topic: "test-ambient", data: expect});
|
||||||
|
port.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
testProfileCleared: function(next) {
|
testProfileCleared: function(next) {
|
||||||
@ -96,19 +101,22 @@ let tests = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
testCookies: function(next) {
|
testCookies: function(next) {
|
||||||
provider.port.onmessage = function onMessage(event) {
|
let port = provider.getWorkerPort();
|
||||||
|
port.onmessage = function onMessage(event) {
|
||||||
let {topic, data} = event.data;
|
let {topic, data} = event.data;
|
||||||
if (topic == "test.cookies-get-response") {
|
if (topic == "test.cookies-get-response") {
|
||||||
is(data.length, 1, "got one cookie");
|
is(data.length, 1, "got one cookie");
|
||||||
is(data[0].name, "cheez", "cookie has the correct name");
|
is(data[0].name, "cheez", "cookie has the correct name");
|
||||||
is(data[0].value, "burger", "cookie has the correct value");
|
is(data[0].value, "burger", "cookie has the correct value");
|
||||||
Services.cookies.remove('.example.com', '/', 'cheez', false);
|
Services.cookies.remove('.example.com', '/', 'cheez', false);
|
||||||
|
port.close();
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var MAX_EXPIRY = Math.pow(2, 62);
|
var MAX_EXPIRY = Math.pow(2, 62);
|
||||||
Services.cookies.add('.example.com', '/', 'cheez', 'burger', false, false, true, MAX_EXPIRY);
|
Services.cookies.add('.example.com', '/', 'cheez', 'burger', false, false, true, MAX_EXPIRY);
|
||||||
provider.port.postMessage({topic: "test.cookies-get"});
|
port.postMessage({topic: "test-initialization"});
|
||||||
|
port.postMessage({topic: "test.cookies-get"});
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -5,11 +5,12 @@
|
|||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
|
// NOTE: none of the manifests here can have a workerURL set, or we attempt
|
||||||
|
// to create a FrameWorker and that fails under xpcshell...
|
||||||
let manifests = [
|
let manifests = [
|
||||||
{ // normal provider
|
{ // normal provider
|
||||||
name: "provider 1",
|
name: "provider 1",
|
||||||
origin: "https://example1.com",
|
origin: "https://example1.com",
|
||||||
workerURL: "https://example1.com/worker.js"
|
|
||||||
},
|
},
|
||||||
{ // provider without workerURL
|
{ // provider without workerURL
|
||||||
name: "provider 2",
|
name: "provider 2",
|
||||||
|
Loading…
Reference in New Issue
Block a user