diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index e148fcf7877..8d07393537c 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -15,6 +15,7 @@ pref("browser.chromeURL", "chrome://b2g/content/"); // so that it can't be set a just a string. // data: url is a workaround this. pref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=chrome://b2g/content/shell.html"); +pref("b2g.is_mulet", true); // Prevent having the firstrun page pref("startup.homepage_welcome_url", ""); pref("browser.shell.checkDefaultBrowser", false); diff --git a/b2g/config/dolphin/sources.xml b/b2g/config/dolphin/sources.xml index cbfacf1e020..a5577693329 100644 --- a/b2g/config/dolphin/sources.xml +++ b/b2g/config/dolphin/sources.xml @@ -15,7 +15,7 @@ - + @@ -23,7 +23,7 @@ - + diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index bac2f4a9615..b3ad3c8f40e 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,13 +19,13 @@ - + - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 041ca6e3289..03b26ea2959 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,10 +17,10 @@ - + - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index f2ed8bd91e9..d97cfc53830 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + @@ -23,7 +23,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index bac2f4a9615..b3ad3c8f40e 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,13 +19,13 @@ - + - + diff --git a/b2g/config/flame-kk/sources.xml b/b2g/config/flame-kk/sources.xml index de206023a07..ac6d2482ac6 100644 --- a/b2g/config/flame-kk/sources.xml +++ b/b2g/config/flame-kk/sources.xml @@ -15,7 +15,7 @@ - + @@ -23,7 +23,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index f3a4e502395..c08a0e3bfcd 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,10 +17,10 @@ - + - + diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 98279373767..810ac714a89 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "d7e815eb184c843a9d7e5784e99d5e39a31c59da", + "revision": "9a69c3f26819cc3ee8060307289ca8712d0c5e22", "repo_path": "integration/gaia-central" } diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index e4114be5e34..7e1d371c8e0 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,11 +17,11 @@ - + - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index cd9f4b39ea1..2ccbce2c313 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index ce5a63593d6..d3940be1ea1 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,10 +17,10 @@ - + - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index a91d49d7962..c5845d8a50e 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,12 +17,12 @@ - + - + diff --git a/dom/apps/PermissionsTable.jsm b/dom/apps/PermissionsTable.jsm index 9887e90b148..e02d771afd7 100644 --- a/dom/apps/PermissionsTable.jsm +++ b/dom/apps/PermissionsTable.jsm @@ -411,8 +411,13 @@ this.PermissionsTable = { geolocation: { app: DENY_ACTION, trusted: DENY_ACTION, privileged: DENY_ACTION, - certified: ALLOW_ACTION, - access: ["read", "write"] + certified: ALLOW_ACTION + }, + "nfc-share": { + app: DENY_ACTION, + trusted: DENY_ACTION, + privileged: DENY_ACTION, + certified: ALLOW_ACTION }, "nfc-manager": { app: DENY_ACTION, diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index ade5c650223..1ba5d75ea83 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -1414,6 +1414,19 @@ Navigator::GetFeature(const nsAString& aName, ErrorResult& aRv) } // hardware.memory #endif + p->MaybeResolve(JS::UndefinedHandleValue); + return p.forget(); +} + +already_AddRefed +Navigator::HasFeature(const nsAString& aName, ErrorResult& aRv) +{ + nsCOMPtr go = do_QueryInterface(mWindow); + nsRefPtr p = Promise::Create(go, aRv); + if (aRv.Failed()) { + return nullptr; + } + // Hardcoded manifest features. Some are still b2g specific. const char manifestFeatures[][64] = { "manifest.origin" @@ -1432,19 +1445,6 @@ Navigator::GetFeature(const nsAString& aName, ErrorResult& aRv) } } - p->MaybeResolve(JS::UndefinedHandleValue); - return p.forget(); -} - -already_AddRefed -Navigator::HasFeature(const nsAString& aName, ErrorResult& aRv) -{ - nsCOMPtr go = do_QueryInterface(mWindow); - nsRefPtr p = Promise::Create(go, aRv); - if (aRv.Failed()) { - return nullptr; - } - NS_NAMED_LITERAL_STRING(apiWindowPrefix, "api.window."); if (StringBeginsWith(aName, apiWindowPrefix)) { const nsAString& featureName = Substring(aName, apiWindowPrefix.Length()); diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index e5f142f8279..14873d855b7 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -52,6 +52,7 @@ #include "nsIPermissionManager.h" #include "nsISHistory.h" #include "nsNullPrincipal.h" +#include "nsIScriptError.h" #include "nsLayoutUtils.h" #include "nsView.h" @@ -1762,6 +1763,30 @@ nsFrameLoader::MaybeCreateDocShell() NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js"), /* allowDelayedLoad = */ true, /* aRunInGlobalScope */ true); + // For inproc frames, set the docshell properties. + nsCOMPtr item = do_GetInterface(docShell); + nsAutoString name; + if (mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name)) { + item->SetName(name); + } + mDocShell->SetFullscreenAllowed( + mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) || + mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen)); + bool isPrivate = mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::mozprivatebrowsing); + if (isPrivate) { + bool nonBlank; + mDocShell->GetHasLoadedNonBlankURI(&nonBlank); + if (nonBlank) { + nsContentUtils::ReportToConsoleNonLocalized( + NS_LITERAL_STRING("We should not switch to Private Browsing after loading a document."), + nsIScriptError::warningFlag, + NS_LITERAL_CSTRING("mozprivatebrowsing"), + nullptr); + } else { + nsCOMPtr context = do_GetInterface(mDocShell); + context->SetUsePrivateBrowsing(true); + } + } } return NS_OK; diff --git a/dom/base/test/test_getFeature_with_perm.html b/dom/base/test/test_getFeature_with_perm.html index af31a4fec32..41ad4921d1d 100644 --- a/dom/base/test/test_getFeature_with_perm.html +++ b/dom/base/test/test_getFeature_with_perm.html @@ -51,18 +51,27 @@ function testNotSupported() { ok(typeof tv === 'undefined', "Resolve the Promise with undefined value (hardware.tv)"); runNextTest(); },function(tv) { - ok(false, "The Promise should not be rejected") + ok(false, "The Promise should not be rejected"); + }); +} + +function testNotSupportedManifest() { + navigator.getFeature("manifest.origin").then(function(feature) { + ok(typeof feature == 'undefined', "manifest.* resolves with undefined on getFeature"); + runNextTest(); + }, function() { + ok(false, "The Promise should not be rejected"); }); } function createManifestTest(aFeature) { return function() { var res; - navigator.getFeature(aFeature).then(function(res) { + navigator.hasFeature(aFeature).then(function(res) { ok(res === true, "Resolve the Promise with 'true' for " + aFeature); runNextTest(); - },function(tv) { - ok(false, "The Promise should not be rejected") + }, function(tv) { + ok(false, "The Promise should not be rejected"); }); } } @@ -70,6 +79,7 @@ function createManifestTest(aFeature) { var currentTest = -1; var tests = [ testNotSupported, + testNotSupportedManifest, testSupported, createManifestTest("manifest.origin"), createManifestTest("manifest.redirects") @@ -90,6 +100,7 @@ SpecialPowers.pushPermissions([ {type: "feature-detection", allow: 1, context: document} ], function() { ok('getFeature' in navigator, "navigator.getFeature should exist"); + ok('hasFeature' in navigator, "navigator.hasFeature should exist"); // B2G specific manifest features. // Touching navigator before pushPermissions makes it fail. if (!navigator.userAgent.contains("Android") && diff --git a/dom/browser-element/BrowserElementChild.js b/dom/browser-element/BrowserElementChild.js index 4996b178e0f..81747115e43 100644 --- a/dom/browser-element/BrowserElementChild.js +++ b/dom/browser-element/BrowserElementChild.js @@ -52,14 +52,5 @@ if (!('BrowserElementIsPreloaded' in this)) { var BrowserElementIsReady = true; -let infos = sendSyncMessage('browser-element-api:call', - { 'msg_name': 'hello' })[0]; -docShell.QueryInterface(Ci.nsIDocShellTreeItem).name = infos.name; -docShell.setFullscreenAllowed(infos.fullscreenAllowed); -if (infos.isPrivate) { - if (docShell.hasLoadedNonBlankURI) { - Cu.reportError("We should not switch to Private Browsing after loading a document."); - } else { - docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true; - } -} + +sendAsyncMessage('browser-element-api:call', { 'msg_name': 'hello' }); diff --git a/dom/browser-element/BrowserElementParent.js b/dom/browser-element/BrowserElementParent.js index 038434fa1f5..42f9a94c267 100644 --- a/dom/browser-element/BrowserElementParent.js +++ b/dom/browser-element/BrowserElementParent.js @@ -325,14 +325,6 @@ BrowserElementParent.prototype = { this._domRequestReady = true; this._runPendingAPICall(); } - - return { - name: this._frameElement.getAttribute('name'), - fullscreenAllowed: - this._frameElement.hasAttribute('allowfullscreen') || - this._frameElement.hasAttribute('mozallowfullscreen'), - isPrivate: this._frameElement.hasAttribute('mozprivatebrowsing') - }; }, _fireCtxMenuEvent: function(data) { diff --git a/dom/browser-element/mochitest/file_browserElement_SetVisibleFrames2_Outer.html b/dom/browser-element/mochitest/file_browserElement_SetVisibleFrames2_Outer.html index 3694f621705..c4fa25d26bb 100644 --- a/dom/browser-element/mochitest/file_browserElement_SetVisibleFrames2_Outer.html +++ b/dom/browser-element/mochitest/file_browserElement_SetVisibleFrames2_Outer.html @@ -15,10 +15,6 @@ iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { }, 0); }, 0); } - else { - // Pass the message up to our parent. - alert(e.detail.message); - } }); document.body.appendChild(iframe); diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 93f34ffa8df..aec8a18047c 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -69,6 +69,13 @@ union MaybeNativeKeyBinding void_t; }; +struct ShowInfo +{ + nsString name; + bool fullscreenAllowed; + bool isPrivate; +}; + prio(normal upto urgent) intr protocol PBrowser { manager PContent or PContentBridge; @@ -411,6 +418,7 @@ child: * point. */ Show(nsIntSize size, + ShowInfo info, ScrollingBehavior scrolling, TextureFactoryIdentifier textureFactoryIdentifier, uint64_t layersId, diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 7d850ba69dc..cd343643580 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -90,6 +90,7 @@ #include "nsIAppsService.h" #include "nsNetUtil.h" #include "nsIPermissionManager.h" +#include "nsIScriptError.h" #define BROWSER_ELEMENT_CHILD_SCRIPT \ NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js") @@ -1881,10 +1882,36 @@ TabChild::DoFakeShow(const ScrollingBehavior& aScrolling, const uint64_t& aLayersId, PRenderFrameChild* aRenderFrame) { - RecvShow(nsIntSize(0, 0), aScrolling, aTextureFactoryIdentifier, aLayersId, aRenderFrame); + ShowInfo info(EmptyString(), false, false); + RecvShow(nsIntSize(0, 0), info, aScrolling, aTextureFactoryIdentifier, aLayersId, aRenderFrame); mDidFakeShow = true; } +void +TabChild::ApplyShowInfo(const ShowInfo& aInfo) +{ + nsCOMPtr docShell = do_GetInterface(WebNavigation()); + if (docShell) { + nsCOMPtr item = do_GetInterface(docShell); + item->SetName(aInfo.name()); + docShell->SetFullscreenAllowed(aInfo.fullscreenAllowed()); + if (aInfo.isPrivate()) { + bool nonBlank; + docShell->GetHasLoadedNonBlankURI(&nonBlank); + if (nonBlank) { + nsContentUtils::ReportToConsoleNonLocalized( + NS_LITERAL_STRING("We should not switch to Private Browsing after loading a document."), + nsIScriptError::warningFlag, + NS_LITERAL_CSTRING("mozprivatebrowsing"), + nullptr); + } else { + nsCOMPtr context = do_GetInterface(docShell); + context->SetUsePrivateBrowsing(true); + } + } + } +} + #ifdef MOZ_WIDGET_GONK void TabChild::MaybeRequestPreinitCamera() @@ -1945,6 +1972,7 @@ TabChild::MaybeRequestPreinitCamera() bool TabChild::RecvShow(const nsIntSize& aSize, + const ShowInfo& aInfo, const ScrollingBehavior& aScrolling, const TextureFactoryIdentifier& aTextureFactoryIdentifier, const uint64_t& aLayersId, @@ -1953,6 +1981,7 @@ TabChild::RecvShow(const nsIntSize& aSize, MOZ_ASSERT((!mDidFakeShow && aRenderFrame) || (mDidFakeShow && !aRenderFrame)); if (mDidFakeShow) { + ApplyShowInfo(aInfo); return true; } @@ -1976,7 +2005,9 @@ TabChild::RecvShow(const nsIntSize& aSize, MaybeRequestPreinitCamera(); #endif - return InitTabChildGlobal(); + bool res = InitTabChildGlobal(); + ApplyShowInfo(aInfo); + return res; } bool diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index ff0243a5e5e..8b84a78fdd2 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -317,6 +317,7 @@ public: const FileDescriptor& aFileDescriptor) MOZ_OVERRIDE; virtual bool RecvShow(const nsIntSize& aSize, + const ShowInfo& aInfo, const ScrollingBehavior& aScrolling, const TextureFactoryIdentifier& aTextureFactoryIdentifier, const uint64_t& aLayersId, @@ -552,6 +553,8 @@ private: const uint64_t& aLayersId, PRenderFrameChild* aRenderFrame); + void ApplyShowInfo(const ShowInfo& aInfo); + // These methods are used for tracking synthetic mouse events // dispatched for compatibility. On each touch event, we // UpdateTapState(). If we've detected that the current gesture diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 7f9f1b4e68e..0b065ce9585 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -600,7 +600,19 @@ TabParent::Show(const nsIntSize& size) unused << SendPRenderFrameConstructor(renderFrame); } } - unused << SendShow(size, scrolling, textureFactoryIdentifier, layersId, renderFrame); + + ShowInfo info(EmptyString(), false, false); + if (mFrameElement) { + nsAutoString name; + mFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name); + bool allowFullscreen = + mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) || + mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen); + bool isPrivate = mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::mozprivatebrowsing); + info = ShowInfo(name, allowFullscreen, isPrivate); + } + + unused << SendShow(size, info, scrolling, textureFactoryIdentifier, layersId, renderFrame); } void diff --git a/dom/nfc/NfcContentHelper.js b/dom/nfc/NfcContentHelper.js index 362a7ae8311..6838ae581aa 100644 --- a/dom/nfc/NfcContentHelper.js +++ b/dom/nfc/NfcContentHelper.js @@ -131,21 +131,6 @@ NfcContentHelper.prototype = { return encodedRecords; }, - // NFC interface: - checkSessionToken: function checkSessionToken(sessionToken, isP2P) { - if (sessionToken == null) { - throw Components.Exception("No session token!", - Cr.NS_ERROR_UNEXPECTED); - return false; - } - // Report session to Nfc.js only. - let val = cpmm.sendSyncMessage("NFC:CheckSessionToken", { - sessionToken: sessionToken, - isP2P: isP2P - }); - return (val[0] === NFC.NFC_GECKO_SUCCESS); - }, - // NFCTag interface readNDEF: function readNDEF(sessionToken, callback) { let requestId = callback.getCallbackId(); diff --git a/dom/nfc/gonk/Nfc.js b/dom/nfc/gonk/Nfc.js index 080f852cd89..4139c009e07 100644 --- a/dom/nfc/gonk/Nfc.js +++ b/dom/nfc/gonk/Nfc.js @@ -54,25 +54,21 @@ const NFC_CONTRACTID = "@mozilla.org/nfc;1"; const NFC_CID = Components.ID("{2ff24790-5e74-11e1-b86c-0800200c9a66}"); -const NFC_IPC_ADD_EVENT_TARGET_MSG_NAMES = [ - "NFC:AddEventListener" -]; - const NFC_IPC_MSG_NAMES = [ - "NFC:CheckSessionToken", + "NFC:AddEventListener", "NFC:QueryInfo" ]; -const NFC_IPC_READ_PERM_MSG_NAMES = [ +const NFC_IPC_NFC_PERM_MSG_NAMES = [ "NFC:ReadNDEF", "NFC:Connect", "NFC:Close", -]; - -const NFC_IPC_WRITE_PERM_MSG_NAMES = [ "NFC:WriteNDEF", "NFC:MakeReadOnly", "NFC:Format", +]; + +const NFC_IPC_NFC_SHARE_PERM_MSG_NAMES = [ "NFC:SendFile", "NFC:RegisterPeerReadyTarget", "NFC:UnregisterPeerReadyTarget" @@ -131,19 +127,15 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () { _registerMessageListeners: function _registerMessageListeners() { ppmm.addMessageListener("child-process-shutdown", this); - for (let message of NFC_IPC_ADD_EVENT_TARGET_MSG_NAMES) { - ppmm.addMessageListener(message, this); - } - for (let message of NFC_IPC_MSG_NAMES) { ppmm.addMessageListener(message, this); } - for (let message of NFC_IPC_READ_PERM_MSG_NAMES) { + for (let message of NFC_IPC_NFC_PERM_MSG_NAMES) { ppmm.addMessageListener(message, this); } - for (let message of NFC_IPC_WRITE_PERM_MSG_NAMES) { + for (let message of NFC_IPC_NFC_SHARE_PERM_MSG_NAMES) { ppmm.addMessageListener(message, this); } @@ -155,19 +147,15 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () { _unregisterMessageListeners: function _unregisterMessageListeners() { ppmm.removeMessageListener("child-process-shutdown", this); - for (let message of NFC_IPC_ADD_EVENT_TARGET_MSG_NAMES) { - ppmm.removeMessageListener(message, this); - } - for (let message of NFC_IPC_MSG_NAMES) { ppmm.removeMessageListener(message, this); } - for (let message of NFC_IPC_READ_PERM_MSG_NAMES) { + for (let message of NFC_IPC_NFC_PERM_MSG_NAMES) { ppmm.removeMessageListener(message, this); } - for (let message of NFC_IPC_WRITE_PERM_MSG_NAMES) { + for (let message of NFC_IPC_NFC_SHARE_PERM_MSG_NAMES) { ppmm.removeMessageListener(message, this); } @@ -290,19 +278,18 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () { return null; } - if (NFC_IPC_MSG_NAMES.indexOf(message.name) != -1 || - NFC_IPC_ADD_EVENT_TARGET_MSG_NAMES.indexOf(message.name) != -1 ) { + if (NFC_IPC_MSG_NAMES.indexOf(message.name) != -1) { // Do nothing. - } else if (NFC_IPC_READ_PERM_MSG_NAMES.indexOf(message.name) != -1) { - if (!message.target.assertPermission("nfc-read")) { - debug("Nfc message " + message.name + - " from a content process with no 'nfc-read' privileges."); + } else if (NFC_IPC_NFC_PERM_MSG_NAMES.indexOf(message.name) != -1) { + if (!message.target.assertPermission("nfc")) { + debug("Nfc Peer message " + message.name + + " from a content process with no 'nfc' privileges."); return null; } - } else if (NFC_IPC_WRITE_PERM_MSG_NAMES.indexOf(message.name) != -1) { - if (!message.target.assertPermission("nfc-write")) { + } else if (NFC_IPC_NFC_SHARE_PERM_MSG_NAMES.indexOf(message.name) != -1) { + if (!message.target.assertPermission("nfc-share")) { debug("Nfc Peer message " + message.name + - " from a content process with no 'nfc-write' privileges."); + " from a content process with no 'nfc-share' privileges."); return null; } } else if (NFC_IPC_MANAGER_PERM_MSG_NAMES.indexOf(message.name) != -1) { @@ -320,11 +307,6 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () { case "NFC:AddEventListener": this.addEventListener(message.target); return null; - case "NFC:CheckSessionToken": - let sessionToken = message.data.sessionToken; - return SessionHelper.isValidToken(sessionToken, message.data.isP2P) ? - NFC.NFC_GECKO_SUCCESS : - NFC.NFC_GECKO_ERROR_BAD_SESSION_TOKEN; case "NFC:RegisterPeerReadyTarget": this.registerPeerReadyTarget(message.target, message.data.appId); return null; @@ -341,7 +323,7 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () { // Upon receiving the status of sendFile operation, send the response // to appropriate content process. message.data.type = "NotifySendFileStatusResponse"; - if (message.data.status !== NFC.NFC_SUCCESS) { + if (message.data.status) { message.data.errorMsg = this.nfc.getErrorMessage(NFC.NFC_GECKO_ERROR_SEND_FILE_FAILED); } @@ -421,17 +403,6 @@ let SessionHelper = { isP2PSession: function isP2PSession(id) { return (this.tokenMap[id] != null) && this.tokenMap[id].isP2P; - }, - - isValidToken: function isValidToken(token, isP2P) { - for (let id in this.tokenMap) { - if ((this.tokenMap[id].token == token) && - (this.tokenMap[id].isP2P == isP2P)) { - return true; - } - } - - return false; } }; @@ -511,8 +482,7 @@ Nfc.prototype = { }, getErrorMessage: function getErrorMessage(errorCode) { - return NFC.NFC_ERROR_MSG[errorCode] || - NFC.NFC_ERROR_MSG[NFC.NFC_GECKO_ERROR_GENERIC_FAILURE]; + return NFC.NFC_ERROR_MSG[errorCode]; }, /** diff --git a/dom/nfc/gonk/nfc_consts.js b/dom/nfc/gonk/nfc_consts.js index 72f88c050df..ad28542cd43 100644 --- a/dom/nfc/gonk/nfc_consts.js +++ b/dom/nfc/gonk/nfc_consts.js @@ -23,17 +23,12 @@ this.DEBUG_CONTENT_HELPER = DEBUG_ALL || false; this.DEBUG_NFC = DEBUG_ALL || false; // Gecko specific error codes -this.NFC_GECKO_SUCCESS = 0; -this.NFC_GECKO_ERROR_GENERIC_FAILURE = 1; -this.NFC_GECKO_ERROR_P2P_REG_INVALID = 2; -this.NFC_GECKO_ERROR_SEND_FILE_FAILED = 3; -this.NFC_GECKO_ERROR_BAD_SESSION_TOKEN = 4; +this.NFC_GECKO_ERROR_P2P_REG_INVALID = 1; +this.NFC_GECKO_ERROR_SEND_FILE_FAILED = 2; this.NFC_ERROR_MSG = {}; -this.NFC_ERROR_MSG[this.NFC_GECKO_ERROR_GENERIC_FAILURE] = "NfcGenericFailureError"; this.NFC_ERROR_MSG[this.NFC_GECKO_ERROR_P2P_REG_INVALID] = "NfcP2PRegistrationInvalid"; this.NFC_ERROR_MSG[this.NFC_GECKO_ERROR_SEND_FILE_FAILED] = "NfcSendFileFailed"; -this.NFC_ERROR_MSG[this.NFC_GECKO_ERROR_BAD_SESSION_TOKEN] = "NfcBadSessionToken"; this.NFC_RF_STATE_IDLE = "idle"; this.NFC_RF_STATE_LISTEN = "listen"; diff --git a/dom/nfc/nsINfcContentHelper.idl b/dom/nfc/nsINfcContentHelper.idl index a63edb8795c..16cfed1878c 100644 --- a/dom/nfc/nsINfcContentHelper.idl +++ b/dom/nfc/nsINfcContentHelper.idl @@ -87,13 +87,11 @@ interface nsINfcRequestCallback : nsISupports void notifyError(in DOMString errorMsg); }; -[scriptable, uuid(bcf214de-885b-43e6-9e53-9b7d880e1633)] +[scriptable, uuid(c5fdf956-735e-45d3-aa25-3a871bd3e2f8)] interface nsINfcContentHelper : nsISupports { void init(in nsIDOMWindow window); - boolean checkSessionToken(in DOMString sessionToken, in boolean isP2P); - /** * Read current NDEF data on the tag. * diff --git a/dom/nfc/nsNfc.js b/dom/nfc/nsNfc.js index 2887d8f8950..deee381dde2 100644 --- a/dom/nfc/nsNfc.js +++ b/dom/nfc/nsNfc.js @@ -332,23 +332,6 @@ MozNFCImpl.prototype = { return callback.promise; }, - _createNFCPeer: function _createNFCPeer(sessionToken) { - let peer = new MozNFCPeerImpl(this._window, sessionToken); - return this._window.MozNFCPeer._create(this._window, peer); - }, - - getNFCPeer: function getNFCPeer(sessionToken) { - if (!sessionToken || !this._nfcContentHelper.checkSessionToken(sessionToken, true)) { - return null; - } - - if (!this.nfcPeer || this.nfcPeer.session != sessionToken) { - this.nfcPeer = this._createNFCPeer(sessionToken); - } - - return this.nfcPeer; - }, - defineEventHandlerGetterSetter: function defineEventHandlerGetterSetter(name) { Object.defineProperty(this, name, { get: function get() { @@ -389,7 +372,7 @@ MozNFCImpl.prototype = { return; } - if (!this.checkPermissions(["nfc-read", "nfc-write"])) { + if (!this.checkPermissions(["nfc"])) { return; } @@ -426,7 +409,7 @@ MozNFCImpl.prototype = { return; } - if (!this.checkPermissions(["nfc-read", "nfc-write"])) { + if (!this.checkPermissions(["nfc"])) { return; } @@ -461,14 +444,16 @@ MozNFCImpl.prototype = { return; } - if (!this.checkPermissions(["nfc-write"])) { + let perm = isPeerReady ? ["nfc-share"] : ["nfc"]; + if (!this.checkPermissions(perm)) { return; } this.eventService.addSystemEventListener(this._window, "visibilitychange", this, /* useCapture */false); - this.nfcPeer = this._createNFCPeer(sessionToken); + let peerImpl = new MozNFCPeerImpl(this._window, sessionToken); + this.nfcPeer = this._window.MozNFCPeer._create(this._window, peerImpl) let eventData = { "peer": this.nfcPeer }; let type = (isPeerReady) ? "peerready" : "peerfound"; @@ -483,7 +468,7 @@ MozNFCImpl.prototype = { return; } - if (!this.checkPermissions(["nfc-write"])) { + if (!this.checkPermissions(["nfc", "nfc-share"])) { return; } diff --git a/dom/nfc/tests/marionette/test_nfc_checkP2PRegistration.js b/dom/nfc/tests/marionette/test_nfc_checkP2PRegistration.js index e4e80c73fb0..81a3b623a73 100644 --- a/dom/nfc/tests/marionette/test_nfc_checkP2PRegistration.js +++ b/dom/nfc/tests/marionette/test_nfc_checkP2PRegistration.js @@ -146,11 +146,11 @@ let tests = [ /** * nfc-manager for mozNfc.checkP2PRegistration(manifestUrl) * -> "NFC:CheckP2PRegistration" IPC - * nfc-write to set/unset onpeerready + * nfc-share to set/unset onpeerready * -> "NFC:RegisterPeerTarget", "NFC:UnregisterPeerTarget" IPC */ SpecialPowers.pushPermissions( [ {'type': 'nfc-manager', 'allow': true, context: document}, - {'type': 'nfc-write', 'allow': true, context: document} + {'type': 'nfc-share', 'allow': true, context: document} ], runTests); diff --git a/dom/nfc/tests/marionette/test_nfc_error_messages.js b/dom/nfc/tests/marionette/test_nfc_error_messages.js index 4a91f2c758e..60388fc3858 100644 --- a/dom/nfc/tests/marionette/test_nfc_error_messages.js +++ b/dom/nfc/tests/marionette/test_nfc_error_messages.js @@ -146,11 +146,11 @@ let tests = [ /** * nfc-manager for mozNfc.checkP2PRegistration(manifestUrl) * -> "NFC:CheckP2PRegistration" IPC - * nfc-write to set/unset onpeerready + * nfc-share to set/unset onpeerready * -> "NFC:RegisterPeerTarget", "NFC:UnregisterPeerTarget" IPC */ SpecialPowers.pushPermissions( [ {'type': 'nfc-manager', 'allow': true, context: document}, - {'type': 'nfc-write', 'allow': true, context: document} + {'type': 'nfc-share', 'allow': true, context: document} ], runTests); diff --git a/dom/nfc/tests/marionette/test_nfc_peer.js b/dom/nfc/tests/marionette/test_nfc_peer.js index fb184e7e23a..2ab480b8101 100644 --- a/dom/nfc/tests/marionette/test_nfc_peer.js +++ b/dom/nfc/tests/marionette/test_nfc_peer.js @@ -66,10 +66,7 @@ function testPeerReady() { function testGetNFCPeer() { sysMsgHelper.waitForTechDiscovered(function (msg) { - let peer = nfc.getNFCPeer(msg.sessionToken); - ok(peer instanceof MozNFCPeer, "Should get a NFCPeer object."); - let peer1 = nfc.getNFCPeer(msg.sessionToken); - ok(peer == peer1, "Should get the same MozNFCPeer object"); + ok(msg.peer instanceof MozNFCPeer, "Should get a NFCPeer object."); NCI.deactivate().then(() => toggleNFC(false)).then(runNextTest); }); @@ -181,24 +178,17 @@ function testPeerShouldThrow() { .then(() => NCI.activateRE(emulator.P2P_RE_INDEX_0)); } -function testPeerInvalidToken() { - log("testPeerInvalidToken"); - let peer = nfc.getNFCPeer("fakeSessionToken"); - is(peer, null, "NFCPeer should be null on wrong session token"); - - runNextTest(); -} - let tests = [ testPeerReady, testGetNFCPeer, testCheckP2PRegFailure, testPeerLostShouldBeCalled, testPeerLostShouldNotBeCalled, - testPeerShouldThrow, - testPeerInvalidToken + testPeerShouldThrow ]; SpecialPowers.pushPermissions( [{"type": "nfc-manager", "allow": true, context: document}, - {"type": "nfc-write", "allow": true, context: document}], runTests); + {"type": "nfc", "allow": true, context: document}, + {"type": "nfc-share", "allow": true, context: document}], runTests); + diff --git a/dom/nfc/tests/marionette/test_nfc_peer_sendFile.js b/dom/nfc/tests/marionette/test_nfc_peer_sendFile.js index ee93cf99209..0b1841ec5b2 100644 --- a/dom/nfc/tests/marionette/test_nfc_peer_sendFile.js +++ b/dom/nfc/tests/marionette/test_nfc_peer_sendFile.js @@ -8,8 +8,7 @@ let MANIFEST_URL = "app://system.gaiamobile.org/manifest.webapp"; function sendFile(msg) { log("sendFile msg="+JSON.stringify(msg)); - let peer = nfc.getNFCPeer(msg.sessionToken); - ok(peer instanceof MozNFCPeer, "should get a MozNFCPeer"); + ok(msg.peer instanceof MozNFCPeer, "should get a MozNFCPeer"); ok(msg.blob instanceof Blob, "should get a Blob"); nfc.peerready = null; diff --git a/dom/nfc/tests/marionette/test_nfc_peer_sendndef.js b/dom/nfc/tests/marionette/test_nfc_peer_sendndef.js index d4da90e4624..f587d1ee105 100644 --- a/dom/nfc/tests/marionette/test_nfc_peer_sendndef.js +++ b/dom/nfc/tests/marionette/test_nfc_peer_sendndef.js @@ -6,13 +6,12 @@ MARIONETTE_HEAD_JS = "head.js"; let url = "https://www.example.com"; -function sendNDEF(techType, sessionToken) { +function sendNDEF(techType, peer) { let tnf = NDEF.TNF_WELL_KNOWN; let type = new Uint8Array(NfcUtils.fromUTF8("U")); let payload = new Uint8Array(NfcUtils.fromUTF8(url)); let ndef = [new MozNDEFRecord({tnf: tnf, type: type, payload: payload})]; - let peer = window.navigator.mozNfc.getNFCPeer(sessionToken); let promise = peer.sendNDEF(ndef); promise.then(() => { log("Successfully sent NDEF message"); @@ -35,7 +34,7 @@ function handleTechnologyDiscoveredRE0(msg) { is(msg.type, "techDiscovered", "check for correct message type"); let index = msg.techList.indexOf("P2P"); isnot(index, -1, "check for \'P2P\' in tech list"); - sendNDEF(msg.techList[index], msg.sessionToken); + sendNDEF(msg.techList[index], msg.peer); } function testOnPeerReadyRE0() { diff --git a/dom/system/gonk/SystemWorkerManager.cpp b/dom/system/gonk/SystemWorkerManager.cpp index 7332817662d..edf8fb6dad2 100644 --- a/dom/system/gonk/SystemWorkerManager.cpp +++ b/dom/system/gonk/SystemWorkerManager.cpp @@ -130,7 +130,7 @@ SystemWorkerManager::Shutdown() mWifiWorker = nullptr; if (mKeyStore) { - mKeyStore->CloseSocket(); + mKeyStore->Shutdown(); mKeyStore = nullptr; } diff --git a/dom/webidl/MozNFC.webidl b/dom/webidl/MozNFC.webidl index 5fa99daddc9..6ccf7730509 100644 --- a/dom/webidl/MozNFC.webidl +++ b/dom/webidl/MozNFC.webidl @@ -28,12 +28,6 @@ enum NfcErrorMessage { [NoInterfaceObject] interface MozNFCManager { - /** - * Returns MozNFCPeer object or null in case of invalid sessionToken - */ - [CheckPermissions="nfc-manager"] - MozNFCPeer? getNFCPeer(DOMString sessionToken); - /** * API to check if the given application's manifest * URL is registered with the Chrome Process or not. @@ -78,7 +72,7 @@ interface MozNFCManager { [JSImplementation="@mozilla.org/navigatorNfc;1", NavigatorProperty="mozNfc", Func="Navigator::HasNFCSupport", - CheckPermissions="nfc-read nfc-write", + CheckPermissions="nfc nfc-share", AvailableIn="CertifiedApps"] interface MozNFC : EventTarget { /** @@ -86,32 +80,28 @@ interface MozNFC : EventTarget { * to share data to the NFCPeer object by calling mozNFC.notifyUserAcceptedP2P. * The event will be type of NFCPeerEvent. */ - [CheckPermissions="nfc-write"] + [CheckPermissions="nfc-share"] attribute EventHandler onpeerready; /** * This event will be fired when a NFCPeer is detected. */ - [CheckPermissions="nfc-write"] attribute EventHandler onpeerfound; /** * This event will be fired when NFCPeer, earlier detected in onpeerready * or onpeerfound, moves out of range. */ - [CheckPermissions="nfc-write"] attribute EventHandler onpeerlost; /** * Ths event will be fired when a NFCTag is detected. */ - [CheckPermissions="nfc-read nfc-write"] attribute EventHandler ontagfound; /** * This event will be fired if the tag detected in ontagfound has been removed. */ - [CheckPermissions="nfc-read nfc-write"] attribute EventHandler ontaglost; }; diff --git a/dom/webidl/MozNFCPeer.webidl b/dom/webidl/MozNFCPeer.webidl index d9c32776651..93770292af8 100644 --- a/dom/webidl/MozNFCPeer.webidl +++ b/dom/webidl/MozNFCPeer.webidl @@ -19,7 +19,7 @@ interface MozNFCPeer { /** * Send file to peer device. */ - [Throws] + [Throws, CheckPermissions="nfc-share"] Promise sendFile(Blob blob); }; diff --git a/dom/webidl/MozNFCPeerEvent.webidl b/dom/webidl/MozNFCPeerEvent.webidl index edbae6fd158..102b21bb167 100644 --- a/dom/webidl/MozNFCPeerEvent.webidl +++ b/dom/webidl/MozNFCPeerEvent.webidl @@ -5,7 +5,7 @@ */ [Constructor(DOMString type, optional MozNFCPeerEventInit eventInitDict), - Func="Navigator::HasNFCSupport", CheckPermissions="nfc-write", + Func="Navigator::HasNFCSupport", CheckPermissions="nfc nfc-share", AvailableIn="CertifiedApps"] interface MozNFCPeerEvent : Event { diff --git a/dom/webidl/MozNFCTagEvent.webidl b/dom/webidl/MozNFCTagEvent.webidl index 1a3c5942805..e4b5cef75ed 100644 --- a/dom/webidl/MozNFCTagEvent.webidl +++ b/dom/webidl/MozNFCTagEvent.webidl @@ -5,7 +5,7 @@ */ [Constructor(DOMString type, optional MozNFCTagEventInit eventInitDict), - Func="Navigator::HasNFCSupport", CheckPermissions="nfc-read nfc-write", + Func="Navigator::HasNFCSupport", CheckPermissions="nfc", AvailableIn="CertifiedApps"] interface MozNFCTagEvent : Event { diff --git a/ipc/keystore/KeyStore.cpp b/ipc/keystore/KeyStore.cpp index 712fac4126a..d9c263d761c 100644 --- a/ipc/keystore/KeyStore.cpp +++ b/ipc/keystore/KeyStore.cpp @@ -1,5 +1,5 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set sw=4 ts=8 et ft=cpp: */ +/* vim: set sw=2 ts=2 et ft=cpp: tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -369,7 +369,92 @@ KeyStoreConnector::GetSocketAddr(const sockaddr_any& aAddr, MOZ_CRASH("This should never be called!"); } +// +// KeyStore::ListenSocket +// + +KeyStore::ListenSocket::ListenSocket(KeyStore* aKeyStore) +: mKeyStore(aKeyStore) +{ + MOZ_ASSERT(mKeyStore); + + MOZ_COUNT_CTOR(KeyStore::ListenSocket); +} + +void +KeyStore::ListenSocket::OnConnectSuccess() +{ + mKeyStore->OnConnectSuccess(LISTEN_SOCKET); + + MOZ_COUNT_DTOR(KeyStore::ListenSocket); +} + +void +KeyStore::ListenSocket::OnConnectError() +{ + mKeyStore->OnConnectError(LISTEN_SOCKET); +} + +void +KeyStore::ListenSocket::OnDisconnect() +{ + mKeyStore->OnDisconnect(LISTEN_SOCKET); +} + +// +// KeyStore::StreamSocket +// + +KeyStore::StreamSocket::StreamSocket(KeyStore* aKeyStore) +: mKeyStore(aKeyStore) +{ + MOZ_ASSERT(mKeyStore); + + MOZ_COUNT_CTOR(KeyStore::StreamSocket); +} + +KeyStore::StreamSocket::~StreamSocket() +{ + MOZ_COUNT_DTOR(KeyStore::StreamSocket); +} + +void +KeyStore::StreamSocket::OnConnectSuccess() +{ + mKeyStore->OnConnectSuccess(STREAM_SOCKET); +} + +void +KeyStore::StreamSocket::OnConnectError() +{ + mKeyStore->OnConnectError(STREAM_SOCKET); +} + +void +KeyStore::StreamSocket::OnDisconnect() +{ + mKeyStore->OnDisconnect(STREAM_SOCKET); +} + +void +KeyStore::StreamSocket::ReceiveSocketData( + nsAutoPtr& aMessage) +{ + mKeyStore->ReceiveSocketData(aMessage); +} + +ConnectionOrientedSocketIO* +KeyStore::StreamSocket::GetIO() +{ + return PrepareAccept(new KeyStoreConnector()); +} + +// +// KeyStore +// + KeyStore::KeyStore() +: mShutdown(false) { MOZ_COUNT_CTOR(KeyStore); ::startKeyStoreService(); @@ -379,19 +464,45 @@ KeyStore::KeyStore() KeyStore::~KeyStore() { MOZ_COUNT_DTOR(KeyStore); + + MOZ_ASSERT(!mListenSocket); + MOZ_ASSERT(!mStreamSocket); } void KeyStore::Shutdown() { + // We set mShutdown first, so that |OnDisconnect| won't try to reconnect. mShutdown = true; - CloseSocket(); + + if (mStreamSocket) { + mStreamSocket->Close(); + mStreamSocket = nullptr; + } + if (mListenSocket) { + mListenSocket->Close(); + mListenSocket = nullptr; + } } void KeyStore::Listen() { - ListenSocket(new KeyStoreConnector()); + // We only allocate one |StreamSocket|, but re-use it for every connection. + if (mStreamSocket) { + mStreamSocket->Close(); + } else { + mStreamSocket = new StreamSocket(this); + } + + if (!mListenSocket) { + // We only ever allocate one |ListenSocket|... + mListenSocket = new ListenSocket(this); + mListenSocket->Listen(new KeyStoreConnector(), mStreamSocket); + } else { + // ... but keep it open. + mListenSocket->Listen(mStreamSocket); + } ResetHandlerInfo(); } @@ -512,25 +623,29 @@ KeyStore::ReadData(UnixSocketRawData *aMessage) void KeyStore::SendResponse(ResponseCode aResponse) { + MOZ_ASSERT(mStreamSocket); + if (aResponse == NO_RESPONSE) return; uint8_t response = (uint8_t)aResponse; UnixSocketRawData* data = new UnixSocketRawData((const void *)&response, 1); - SendSocketData(data); + mStreamSocket->SendSocketData(data); } // Data response void KeyStore::SendData(const uint8_t *aData, int aLength) { + MOZ_ASSERT(mStreamSocket); + unsigned short dataLength = htons(aLength); UnixSocketRawData* length = new UnixSocketRawData((const void *)&dataLength, 2); - SendSocketData(length); + mStreamSocket->SendSocketData(length); UnixSocketRawData* data = new UnixSocketRawData((const void *)aData, aLength); - SendSocketData(data); + mStreamSocket->SendSocketData(data); } void @@ -583,24 +698,43 @@ KeyStore::ReceiveSocketData(nsAutoPtr& aMessage) } void -KeyStore::OnConnectSuccess() +KeyStore::OnConnectSuccess(SocketType aSocketType) { - mShutdown = false; + if (aSocketType == STREAM_SOCKET) { + mShutdown = false; + } } void -KeyStore::OnConnectError() +KeyStore::OnConnectError(SocketType aSocketType) { - if (!mShutdown) { + if (mShutdown) { + return; + } + + if (aSocketType == STREAM_SOCKET) { + // Stream socket error; start listening again Listen(); } } void -KeyStore::OnDisconnect() +KeyStore::OnDisconnect(SocketType aSocketType) { - if (!mShutdown) { - Listen(); + if (mShutdown) { + return; + } + + switch (aSocketType) { + case LISTEN_SOCKET: + // Listen socket disconnected; start anew. + mListenSocket = nullptr; + Listen(); + break; + case STREAM_SOCKET: + // Stream socket disconnected; start listening again. + Listen(); + break; } } diff --git a/ipc/keystore/KeyStore.h b/ipc/keystore/KeyStore.h index 028e0ff9a6c..ebcf5e32359 100644 --- a/ipc/keystore/KeyStore.h +++ b/ipc/keystore/KeyStore.h @@ -1,5 +1,5 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set sw=2 ts=8 et ft=cpp: */ +/* vim: set sw=2 ts=2 et ft=cpp: tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -7,11 +7,12 @@ #ifndef mozilla_ipc_KeyStore_h #define mozilla_ipc_KeyStore_h 1 -#include "mozilla/ipc/UnixSocket.h" #include #include - #include "cert.h" +#include "mozilla/ipc/ListenSocket.h" +#include "mozilla/ipc/StreamSocket.h" +#include "mozilla/ipc/UnixSocketConnector.h" namespace mozilla { namespace ipc { @@ -94,21 +95,69 @@ public: nsAString& aAddrStr); }; -class KeyStore : public mozilla::ipc::UnixSocketConsumer +class KeyStore MOZ_FINAL { public: + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(KeyStore) + KeyStore(); void Shutdown(); private: - virtual ~KeyStore(); + enum SocketType { + LISTEN_SOCKET, + STREAM_SOCKET + }; - virtual void ReceiveSocketData(nsAutoPtr& aMessage); + class ListenSocket MOZ_FINAL : public mozilla::ipc::ListenSocket + { + public: + ListenSocket(KeyStore* aKeyStore); + ListenSocket(); - virtual void OnConnectSuccess(); - virtual void OnConnectError(); - virtual void OnDisconnect(); + // SocketBase + // + + void OnConnectSuccess() MOZ_OVERRIDE; + void OnConnectError() MOZ_OVERRIDE; + void OnDisconnect() MOZ_OVERRIDE; + + private: + KeyStore* mKeyStore; + }; + + class StreamSocket MOZ_FINAL : public mozilla::ipc::StreamSocket + { + public: + StreamSocket(KeyStore* aKeyStore); + ~StreamSocket(); + + // SocketConsumerBase + // + + void OnConnectSuccess() MOZ_OVERRIDE; + void OnConnectError() MOZ_OVERRIDE; + void OnDisconnect() MOZ_OVERRIDE; + + void ReceiveSocketData(nsAutoPtr& aMessage) MOZ_OVERRIDE; + + // ConnectionOrientedSocket + // + + ConnectionOrientedSocketIO* GetIO() MOZ_OVERRIDE; + + private: + KeyStore* mKeyStore; + }; + + ~KeyStore(); + + void ReceiveSocketData(nsAutoPtr& aMessage); + + void OnConnectSuccess(enum SocketType aSocketType); + void OnConnectError(enum SocketType aSocketType); + void OnDisconnect(enum SocketType aSocketType); struct { ProtocolHandlerState state; @@ -128,6 +177,9 @@ private: void SendData(const uint8_t *data, int length); bool mShutdown; + + nsRefPtr mListenSocket; + nsRefPtr mStreamSocket; }; } // namespace ipc diff --git a/testing/marionette/marionette-server.js b/testing/marionette/marionette-server.js index 395d23f046c..29b675f1a96 100644 --- a/testing/marionette/marionette-server.js +++ b/testing/marionette/marionette-server.js @@ -37,8 +37,16 @@ specialpowers.specialPowersObserver.init(); Cu.import("resource://gre/modules/FileUtils.jsm"); Cu.import("resource://gre/modules/NetUtil.jsm"); +function isMulet() { + let isMulet = false; + try { + isMulet = Services.prefs.getBoolPref("b2g.is_mulet"); + } catch (ex) { } + return isMulet; +} + Services.prefs.setBoolPref("marionette.contentListener", false); -let appName = Services.appinfo.name; +let appName = isMulet() ? "B2G" : Services.appinfo.name; let { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); let DevToolsUtils = devtools.require("devtools/toolkit/DevToolsUtils.js"); @@ -2943,10 +2951,9 @@ BrowserObj.prototype = { setBrowser: function BO_setBrowser(win) { switch (appName) { case "Firefox": - if (this.window.location.href.indexOf("chrome://b2g") == -1) { + if (!isMulet()) { this.browser = win.gBrowser; - } - else { + } else { // this is Mulet appName = "B2G"; }