From 8fddaf05128c463d73722770855e26ac4be43adf Mon Sep 17 00:00:00 2001 From: Mark Hammond Date: Wed, 12 Sep 2012 12:48:38 +1000 Subject: [PATCH] Bug 788100 - Remove social.initialize-response message. r=jaws --- .../test/browser_social_mozSocial_API.js | 33 ++++++------------- browser/base/content/test/social_worker.js | 2 +- toolkit/components/social/WorkerAPI.jsm | 5 --- .../social/test/browser/browser_workerAPI.js | 23 +++---------- .../social/test/browser/worker_social.js | 1 - 5 files changed, 15 insertions(+), 49 deletions(-) diff --git a/browser/base/content/test/browser_social_mozSocial_API.js b/browser/base/content/test/browser_social_mozSocial_API.js index 19b6ee51639..bb4e64d98e8 100644 --- a/browser/base/content/test/browser_social_mozSocial_API.js +++ b/browser/base/content/test/browser_social_mozSocial_API.js @@ -29,10 +29,12 @@ var tests = { function triggerIconPanel() { let statusIcons = document.getElementById("social-status-iconbox"); - ok(!statusIcons.firstChild.hidden, "status icon is visible"); - // Click the button to trigger its contentPanel - let panel = document.getElementById("social-notification-panel"); - EventUtils.synthesizeMouseAtCenter(statusIcons.firstChild, {}); + waitForCondition(function() statusIcons.firstChild && !statusIcons.firstChild.hidden, + function() { + // Click the button to trigger its contentPanel + let panel = document.getElementById("social-notification-panel"); + EventUtils.synthesizeMouseAtCenter(statusIcons.firstChild, {}); + }, "Status icon didn't become non-hidden"); } let port = Social.provider.getWorkerPort(); @@ -40,6 +42,10 @@ var tests = { port.onmessage = function (e) { let topic = e.data.topic; switch (topic) { + case "test-init-done": + iconsReady = true; + checkNext(); + break; case "got-panel-message": ok(true, "got panel message"); // Check the panel isn't in our history. @@ -67,24 +73,5 @@ var tests = { } } port.postMessage({topic: "test-init"}); - - // Our worker sets up ambient notification at the same time as it responds to - // the workerAPI initialization. If it's already initialized, we can - // immediately check the icons, otherwise wait for initialization by - // observing the topic sent out by the social service. - if (Social.provider.workerAPI.initialized) { - iconsReady = true; - checkNext(); - } else { - Services.obs.addObserver(function obs() { - Services.obs.removeObserver(obs, "social:ambient-notification-changed"); - // Let the other observers (like the one that updates the UI) run before - // checking the icons. - executeSoon(function () { - iconsReady = true; - checkNext(); - }); - }, "social:ambient-notification-changed", false); - } } } diff --git a/browser/base/content/test/social_worker.js b/browser/base/content/test/social_worker.js index 8d4b3541d3c..1e047d996b9 100644 --- a/browser/base/content/test/social_worker.js +++ b/browser/base/content/test/social_worker.js @@ -11,6 +11,7 @@ onconnect = function(e) { switch (topic) { case "test-init": testPort = port; + port.postMessage({topic: "test-init-done"}); break; case "sidebar-message": sidebarPort = port; @@ -69,7 +70,6 @@ onconnect = function(e) { case "social.initialize": // This is the workerAPI port, respond and set up a notification icon. apiPort = port; - port.postMessage({topic: "social.initialize-response"}); let profile = { portrait: "https://example.com/portrait.jpg", userName: "trickster", diff --git a/toolkit/components/social/WorkerAPI.jsm b/toolkit/components/social/WorkerAPI.jsm index 48e12b7ff92..0c2f05f3698 100644 --- a/toolkit/components/social/WorkerAPI.jsm +++ b/toolkit/components/social/WorkerAPI.jsm @@ -23,8 +23,6 @@ function WorkerAPI(provider, port) { this._port = port; this._port.onmessage = this._handleMessage.bind(this); - this.initialized = false; - // Send an "intro" message so the worker knows this is the port // used for the api. // later we might even include an API version - version 0 for now! @@ -54,9 +52,6 @@ WorkerAPI.prototype = { }, handlers: { - "social.initialize-response": function (data) { - this.initialized = true; - }, "social.user-profile": function (data) { this._provider.updateUserProfile(data); }, diff --git a/toolkit/components/social/test/browser/browser_workerAPI.js b/toolkit/components/social/test/browser/browser_workerAPI.js index 2592af27627..5f68d19d6e6 100644 --- a/toolkit/components/social/test/browser/browser_workerAPI.js +++ b/toolkit/components/social/test/browser/browser_workerAPI.js @@ -24,24 +24,6 @@ function test() { } let tests = { - testInitializeWorker: function(next) { - ok(provider.workerAPI, "provider has a workerAPI"); - is(provider.workerAPI.initialized, false, "workerAPI is not yet initialized"); - - let port = provider.getWorkerPort(); - ok(port, "should be able to get a port from the provider"); - - port.onmessage = function onMessage(event) { - let topic = event.data.topic; - if (topic == "test-initialization-complete") { - is(provider.workerAPI.initialized, true, "workerAPI is now initialized"); - port.close(); - next(); - } - } - port.postMessage({topic: "test-initialization"}); - }, - testProfile: function(next) { let expect = { portrait: "https://example.com/portrait.jpg", @@ -58,12 +40,15 @@ let tests = { is(profile.displayName, expect.displayName, "displayName is set"); is(profile.profileURL, expect.profileURL, "profileURL is set"); + // see below - if not for bug 788368 we could close this earlier. + port.close(); next(); } Services.obs.addObserver(ob, "social:profile-changed", false); let port = provider.getWorkerPort(); port.postMessage({topic: "test-profile", data: expect}); - port.close(); + // theoretically we should be able to close the port here, but bug 788368 + // means that if we do, the worker never sees the test-profile message. }, testAmbientNotification: function(next) { diff --git a/toolkit/components/social/test/browser/worker_social.js b/toolkit/components/social/test/browser/worker_social.js index 8890dd5391a..efc26240b79 100644 --- a/toolkit/components/social/test/browser/worker_social.js +++ b/toolkit/components/social/test/browser/worker_social.js @@ -17,7 +17,6 @@ onconnect = function(e) { switch (topic) { case "social.initialize": apiPort = port; - apiPort.postMessage({topic: "social.initialize-response"}); break; case "test-initialization": testerPort = port;