Backout cbe18f181112 for crashes - bug 1292639

This commit is contained in:
Kannan Vijayan 2016-09-07 13:43:40 -04:00
Родитель ca13da128b
Коммит f671b30c0f
9 изменённых файлов: 22 добавлений и 286 удалений

Просмотреть файл

@ -2635,45 +2635,6 @@ ContentPermissionPrompt.prototype = {
"geo-notification-icon", options);
},
_promptFlyWebPublishServer : function(aRequest) {
var message = "Would you like to let this site start a server accessible to nearby devices and people?";
var actions = [
{
stringId: "flyWebPublishServer.allowPublishServer",
action: Ci.nsIPermissionManager.ALLOW_ACTION,
expireType: Ci.nsIPermissionManager.EXPIRE_SESSION
},
{
stringId: "flyWebPublishServer.denyPublishServer",
action: Ci.nsIPermissionManager.DENY_ACTION,
expireType: Ci.nsIPermissionManager.EXPIRE_SESSION
}
];
let options = {
learnMoreURL: "https://flyweb.github.io",
popupIconURL: "chrome://flyweb/skin/icon-64.png"
};
let browser = this._getBrowserForRequest(aRequest);
let chromeDoc = browser.ownerDocument;
let iconElem = chromeDoc.getElementById("flyweb-publish-server-notification-icon");
if (!iconElem) {
let notificationPopupBox = chromeDoc.getElementById("notification-popup-box");
let notificationIcon = chromeDoc.createElement("image");
notificationIcon.setAttribute("id", "flyweb-publish-server-notification-icon");
notificationIcon.setAttribute("src", "chrome://flyweb/skin/icon-64.png");
notificationIcon.setAttribute("class", "notification-anchor-icon flyweb-publish-server-icon");
notificationIcon.setAttribute("style", "filter: url(chrome://browser/skin/filters.svg#fill); fill: currentColor; opacity: .4;");
notificationIcon.setAttribute("role", "button");
notificationIcon.setAttribute("aria-label", "View the publish-server request");
notificationPopupBox.appendChild(notificationIcon);
}
this._showPrompt(aRequest, message, "flyweb-publish-server", actions, "flyweb-publish-server",
"flyweb-publish-server-notification-icon", options);
},
_promptWebNotifications : function(aRequest) {
var message = gBrowserBundle.GetStringFromName("webNotifications.receiveFromSite");
@ -2738,8 +2699,7 @@ ContentPermissionPrompt.prototype = {
let perm = types.queryElementAt(0, Ci.nsIContentPermissionType);
const kFeatureKeys = { "geolocation" : "geo",
"desktop-notification" : "desktop-notification",
"flyweb-publish-server": "flyweb-publish-server"
"desktop-notification" : "desktop-notification"
};
// Make sure that we support the request.
@ -2782,11 +2742,6 @@ ContentPermissionPrompt.prototype = {
case "desktop-notification":
this._promptWebNotifications(request);
break;
case "flyweb-publish-server":
if (AppConstants.NIGHTLY_BUILD) {
this._promptFlyWebPublishServer(request);
}
break;
}
},

Просмотреть файл

@ -378,16 +378,6 @@ geolocation.neverShareLocation.accesskey=N
geolocation.shareWithSite2=Would you like to share your location with this site?
geolocation.shareWithFile2=Would you like to share your location with this file?
# FlyWeb UI
# LOCALIZATION NOTE (flyWebPublishServer.allowPublishServer): This is an experimental feature only shipping in Nightly, and doesn't need translation.
flyWebPublishServer.allowPublishServer=Allow Server
# LOCALIZATION NOTE (flyWebPublishServer.allowPublishServer.accessKey): This is an experimental feature only shipping in Nightly, and doesn't need translation.
flyWebPublishServer.allowPublishServer.accesskey=A
# LOCALIZATION NOTE (flyWebPublishServer.denyPublishServer): This is an experimental feature only shipping in Nightly, and doesn't need translation.
flyWebPublishServer.denyPublishServer=Block Server
# LOCALIZATION NOTE (flyWebPublishServer.denyPublishServer.accessKey): This is an experimental feature only shipping in Nightly, and doesn't need translation.
flyWebPublishServer.denyPublishServer.accesskey=B
webNotifications.receiveForSession=Receive for this session
webNotifications.receiveForSession.accesskey=s
webNotifications.alwaysReceive=Always Receive Notifications

Просмотреть файл

@ -171,16 +171,6 @@ FlyWebPublishedServerImpl::FlyWebPublishedServerImpl(nsPIDOMWindowInner* aOwner,
, mHttpServer(new HttpServer())
{
LOG_I("FlyWebPublishedServerImpl::FlyWebPublishedServerImpl(%p)", this);
}
void
FlyWebPublishedServerImpl::PermissionGranted(bool aGranted)
{
LOG_I("FlyWebPublishedServerImpl::PermissionGranted(%b)", aGranted);
if (!aGranted) {
PublishedServerStarted(NS_ERROR_FAILURE);
return;
}
mHttpServer->Init(-1, Preferences::GetBool("flyweb.use-tls", false), this);
}
@ -262,37 +252,25 @@ FlyWebPublishedServerChild::FlyWebPublishedServerChild(nsPIDOMWindowInner* aOwne
const nsAString& aName,
const FlyWebPublishOptions& aOptions)
: FlyWebPublishedServer(aOwner, aName, aOptions)
, mActorExists(false)
, mActorDestroyed(false)
{
LOG_I("FlyWebPublishedServerChild::FlyWebPublishedServerChild(%p)", this);
ContentChild::GetSingleton()->
SendPFlyWebPublishedServerConstructor(this,
PromiseFlatString(aName),
aOptions);
// The matching release happens when the actor is destroyed, in
// ContentChild::DeallocPFlyWebPublishedServerChild
NS_ADDREF_THIS();
}
void
FlyWebPublishedServerChild::PermissionGranted(bool aGranted)
{
if (!aGranted) {
PublishedServerStarted(NS_ERROR_FAILURE);
return;
}
mActorExists = true;
FlyWebPublishOptions options;
options.mUiUrl = mUiUrl;
// Proceed with initialization.
ContentChild::GetSingleton()->
SendPFlyWebPublishedServerConstructor(this, mName, options);
}
bool
FlyWebPublishedServerChild::RecvServerReady(const nsresult& aStatus)
{
LOG_I("FlyWebPublishedServerChild::RecvServerReady(%p)", this);
MOZ_ASSERT(mActorExists);
MOZ_ASSERT(!mActorDestroyed);
PublishedServerStarted(aStatus);
return true;
@ -302,7 +280,7 @@ bool
FlyWebPublishedServerChild::RecvServerClose()
{
LOG_I("FlyWebPublishedServerChild::RecvServerClose(%p)", this);
MOZ_ASSERT(mActorExists);
MOZ_ASSERT(!mActorDestroyed);
Close();
@ -314,7 +292,7 @@ FlyWebPublishedServerChild::RecvFetchRequest(const IPCInternalRequest& aRequest,
const uint64_t& aRequestId)
{
LOG_I("FlyWebPublishedServerChild::RecvFetchRequest(%p)", this);
MOZ_ASSERT(mActorExists);
MOZ_ASSERT(!mActorDestroyed);
RefPtr<InternalRequest> request = new InternalRequest(aRequest);
mPendingRequests.Put(request, aRequestId);
@ -329,7 +307,7 @@ FlyWebPublishedServerChild::RecvWebSocketRequest(const IPCInternalRequest& aRequ
PTransportProviderChild* aProvider)
{
LOG_I("FlyWebPublishedServerChild::RecvWebSocketRequest(%p)", this);
MOZ_ASSERT(mActorExists);
MOZ_ASSERT(!mActorDestroyed);
RefPtr<InternalRequest> request = new InternalRequest(aRequest);
mPendingRequests.Put(request, aRequestId);
@ -349,7 +327,7 @@ FlyWebPublishedServerChild::ActorDestroy(ActorDestroyReason aWhy)
{
LOG_I("FlyWebPublishedServerChild::ActorDestroy(%p)", this);
mActorExists = false;
mActorDestroyed = true;
}
void
@ -358,7 +336,7 @@ FlyWebPublishedServerChild::OnFetchResponse(InternalRequest* aRequest,
{
LOG_I("FlyWebPublishedServerChild::OnFetchResponse(%p)", this);
if (!mActorExists) {
if (mActorDestroyed) {
LOG_I("FlyWebPublishedServerChild::OnFetchResponse(%p) - No actor!", this);
return;
}
@ -383,7 +361,7 @@ FlyWebPublishedServerChild::OnWebSocketAcceptInternal(InternalRequest* aRequest,
{
LOG_I("FlyWebPublishedServerChild::OnWebSocketAcceptInternal(%p)", this);
if (!mActorExists) {
if (mActorDestroyed) {
LOG_I("FlyWebPublishedServerChild::OnWebSocketAcceptInternal(%p) - No actor!", this);
return nullptr;
}
@ -422,7 +400,7 @@ FlyWebPublishedServerChild::OnWebSocketResponse(InternalRequest* aRequest,
{
LOG_I("FlyWebPublishedServerChild::OnFetchResponse(%p)", this);
if (!mActorExists) {
if (mActorDestroyed) {
LOG_I("FlyWebPublishedServerChild::OnFetchResponse(%p) - No actor!", this);
return;
}
@ -450,7 +428,7 @@ FlyWebPublishedServerChild::Close()
FlyWebPublishedServer::Close();
if (mActorExists) {
if (!mActorDestroyed) {
LOG_I("FlyWebPublishedServerChild::Close - sending __delete__ (%p)", this);
Send__delete__(this);

Просмотреть файл

@ -57,8 +57,6 @@ public:
aUiUrl = mUiUrl;
}
virtual void PermissionGranted(bool aGranted) = 0;
virtual void OnFetchResponse(InternalRequest* aRequest,
InternalResponse* aResponse) = 0;
already_AddRefed<WebSocket>

Просмотреть файл

@ -50,7 +50,6 @@ public:
}
}
virtual void PermissionGranted(bool aGranted) override;
virtual void OnFetchResponse(InternalRequest* aRequest,
InternalResponse* aResponse) override;
virtual void OnWebSocketResponse(InternalRequest* aConnectRequest,
@ -99,7 +98,6 @@ public:
const nsAString& aName,
const FlyWebPublishOptions& aOptions);
virtual void PermissionGranted(bool aGranted) override;
virtual bool RecvServerReady(const nsresult& aStatus) override;
virtual bool RecvServerClose() override;
virtual bool RecvFetchRequest(const IPCInternalRequest& aRequest,
@ -127,7 +125,7 @@ private:
nsDataHashtable<nsRefPtrHashKey<InternalRequest>, uint64_t> mPendingRequests;
nsRefPtrHashtable<nsUint64HashKey, TransportProviderChild>
mPendingTransportProviders;
bool mActorExists;
bool mActorDestroyed;
};
class FlyWebPublishedServerParent final : public PFlyWebPublishedServerParent

Просмотреть файл

@ -9,7 +9,6 @@
#include "mozilla/ScopeExit.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/FlyWebPublishedServerIPC.h"
#include "mozilla/AddonPathService.h"
#include "nsISocketTransportService.h"
#include "mdns/libmdns/nsDNSServiceInfo.h"
#include "nsIUUIDGenerator.h"
@ -19,7 +18,6 @@
#include "mozilla/dom/FlyWebDiscoveryManagerBinding.h"
#include "prnetdb.h"
#include "DNS.h"
#include "nsContentPermissionHelper.h"
#include "nsSocketTransportService2.h"
#include "nsSocketTransport2.h"
#include "nsHashPropertyBag.h"
@ -36,123 +34,11 @@ struct FlyWebPublishOptions;
static LazyLogModule gFlyWebServiceLog("FlyWebService");
#undef LOG_I
#define LOG_I(...) MOZ_LOG(mozilla::dom::gFlyWebServiceLog, mozilla::LogLevel::Debug, (__VA_ARGS__))
#undef LOG_E
#define LOG_E(...) MOZ_LOG(mozilla::dom::gFlyWebServiceLog, mozilla::LogLevel::Error, (__VA_ARGS__))
#undef LOG_TEST_I
#define LOG_TEST_I(...) MOZ_LOG_TEST(mozilla::dom::gFlyWebServiceLog, mozilla::LogLevel::Debug)
class FlyWebPublishServerPermissionCheck final
: public nsIContentPermissionRequest
, public nsIRunnable
{
public:
NS_DECL_ISUPPORTS
FlyWebPublishServerPermissionCheck(const nsCString& aServiceName, uint64_t aWindowID,
FlyWebPublishedServer* aServer)
: mServiceName(aServiceName)
, mWindowID(aWindowID)
, mServer(aServer)
{}
uint64_t WindowID() const
{
return mWindowID;
}
NS_IMETHOD Run() override
{
MOZ_ASSERT(NS_IsMainThread());
nsGlobalWindow* globalWindow = nsGlobalWindow::GetInnerWindowWithId(mWindowID);
if (!globalWindow) {
return Cancel();
}
mWindow = globalWindow->AsInner();
if (NS_WARN_IF(!mWindow)) {
return Cancel();
}
nsCOMPtr<nsIDocument> doc = mWindow->GetDoc();
if (NS_WARN_IF(!doc)) {
return Cancel();
}
mPrincipal = doc->NodePrincipal();
MOZ_ASSERT(mPrincipal);
mRequester = new nsContentPermissionRequester(mWindow);
return nsContentPermissionUtils::AskPermission(this, mWindow);
}
NS_IMETHOD Cancel() override
{
Resolve(false);
return NS_OK;
}
NS_IMETHOD Allow(JS::HandleValue aChoices) override
{
MOZ_ASSERT(aChoices.isUndefined());
Resolve(true);
return NS_OK;
}
NS_IMETHOD GetTypes(nsIArray** aTypes) override
{
nsTArray<nsString> emptyOptions;
return nsContentPermissionUtils::CreatePermissionArray(NS_LITERAL_CSTRING("flyweb-publish-server"),
NS_LITERAL_CSTRING("unused"), emptyOptions, aTypes);
}
NS_IMETHOD GetRequester(nsIContentPermissionRequester** aRequester) override
{
NS_ENSURE_ARG_POINTER(aRequester);
nsCOMPtr<nsIContentPermissionRequester> requester = mRequester;
requester.forget(aRequester);
return NS_OK;
}
NS_IMETHOD GetPrincipal(nsIPrincipal** aRequestingPrincipal) override
{
NS_IF_ADDREF(*aRequestingPrincipal = mPrincipal);
return NS_OK;
}
NS_IMETHOD GetWindow(mozIDOMWindow** aRequestingWindow) override
{
NS_IF_ADDREF(*aRequestingWindow = mWindow);
return NS_OK;
}
NS_IMETHOD GetElement(nsIDOMElement** aRequestingElement) override
{
*aRequestingElement = nullptr;
return NS_OK;
}
private:
void Resolve(bool aResolve)
{
mServer->PermissionGranted(aResolve);
}
virtual ~FlyWebPublishServerPermissionCheck() = default;
nsCString mServiceName;
uint64_t mWindowID;
RefPtr<FlyWebPublishedServer> mServer;
nsCOMPtr<nsPIDOMWindowInner> mWindow;
nsCOMPtr<nsIPrincipal> mPrincipal;
nsCOMPtr<nsIContentPermissionRequester> mRequester;
};
NS_IMPL_ISUPPORTS(FlyWebPublishServerPermissionCheck,
nsIContentPermissionRequest,
nsIRunnable)
class FlyWebMDNSService final
: public nsIDNSServiceDiscoveryListener
, public nsIDNSServiceResolveListener
@ -955,15 +841,6 @@ FlyWebService::Init()
return ErrorResult(NS_OK);
}
static already_AddRefed<FlyWebPublishPromise>
MakeRejectionPromise(const char* name)
{
MozPromiseHolder<FlyWebPublishPromise> holder;
RefPtr<FlyWebPublishPromise> promise = holder.Ensure(name);
holder.Reject(NS_ERROR_FAILURE, name);
return promise.forget();
}
already_AddRefed<FlyWebPublishPromise>
FlyWebService::PublishServer(const nsAString& aName,
const FlyWebPublishOptions& aOptions,
@ -976,7 +853,10 @@ FlyWebService::PublishServer(const nsAString& aName,
if (existingServer) {
LOG_I("PublishServer: Trying to publish server with already-existing name %s.",
NS_ConvertUTF16toUTF8(aName).get());
return MakeRejectionPromise(__func__);
MozPromiseHolder<FlyWebPublishPromise> holder;
RefPtr<FlyWebPublishPromise> promise = holder.Ensure(__func__);
holder.Reject(NS_ERROR_FAILURE, __func__);
return promise.forget();
}
RefPtr<FlyWebPublishedServer> server;
@ -984,49 +864,6 @@ FlyWebService::PublishServer(const nsAString& aName,
server = new FlyWebPublishedServerChild(aWindow, aName, aOptions);
} else {
server = new FlyWebPublishedServerImpl(aWindow, aName, aOptions);
// Before proceeding, ensure that the FlyWeb system addon exists.
nsresult rv;
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("chrome://flyweb/skin/icon-64.png"));
if (NS_FAILED(rv)) {
return MakeRejectionPromise(__func__);
}
JSAddonId *addonId = MapURIToAddonID(uri);
if (!addonId) {
LOG_E("PublishServer: Failed to find FlyWeb system addon.");
return MakeRejectionPromise(__func__);
}
JSFlatString* flat = JS_ASSERT_STRING_IS_FLAT(JS::StringOfAddonId(addonId));
nsAutoString addonIdString;
AssignJSFlatString(addonIdString, flat);
if (!addonIdString.EqualsLiteral("flyweb@mozilla.org")) {
nsCString addonIdCString = NS_ConvertUTF16toUTF8(addonIdString);
LOG_E("PublishServer: FlyWeb resource found on wrong system addon: %s.", addonIdCString.get());
return MakeRejectionPromise(__func__);
}
}
if (aWindow) {
nsresult rv;
MOZ_ASSERT(NS_IsMainThread());
rv = NS_DispatchToCurrentThread(
MakeAndAddRef<FlyWebPublishServerPermissionCheck>(
NS_ConvertUTF16toUTF8(aName), aWindow->WindowID(), server));
if (NS_WARN_IF(NS_FAILED(rv))) {
LOG_E("PublishServer: Failed to dispatch permission check runnable for %s",
NS_ConvertUTF16toUTF8(aName).get());
return MakeRejectionPromise(__func__);
}
} else {
// If aWindow is null, we're definitely in the e10s parent process.
// In this case, we know that permission has already been granted
// by the user because of content-process prompt.
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
server->PermissionGranted(true);
}
mServers.AppendElement(server);

Просмотреть файл

@ -5,8 +5,7 @@
var PermissionsHelper = {
_permissonTypes: ["password", "geolocation", "popup", "indexedDB",
"offline-app", "desktop-notification", "plugins", "native-intent",
"flyweb-publish-server"],
"offline-app", "desktop-notification", "plugins", "native-intent"],
_permissionStrings: {
"password": {
label: "password.logins",
@ -18,11 +17,6 @@ var PermissionsHelper = {
allowed: "geolocation.allow",
denied: "geolocation.dontAllow"
},
"flyweb-publish-server": {
label: "flyWebPublishServer.publishServer",
allowed: "flyWebPublishServer.allow",
denied: "flyWebPublishServer.dontAllow"
},
"popup": {
label: "blockPopups.label2",
allowed: "popup.show",

Просмотреть файл

@ -18,14 +18,12 @@ const kEntities = {
"device-storage:sdcard": "deviceStorageSdcard",
"device-storage:videos": "deviceStorageVideos",
"geolocation": "geolocation",
"flyweb-publish-server": "flyWebPublishServer",
};
// For these types, prompt for permission if action is unknown.
const PROMPT_FOR_UNKNOWN = [
"desktop-notification",
"geolocation",
"flyweb-publish-server",
];
function ContentPermissionPrompt() {}

Просмотреть файл

@ -131,18 +131,6 @@ desktopNotification2.ask=Would you like to receive notifications from this site?
# used in site settings dialog.
desktopNotification.notifications=Notifications
# FlyWeb UI
# LOCALIZATION NOTE (flyWebPublishServer.allow): This is an experimental feature only shipping in Nightly, and doesn't need translation.
flyWebPublishServer.allow=Allow
# LOCALIZATION NOTE (flyWebPublishServer.dontAllow): This is an experimental feature only shipping in Nightly, and doesn't need translation.
flyWebPublishServer.dontAllow=Deny
# LOCALIZATION NOTE (flyWebPublishServer.ask): This is an experimental feature only shipping in Nightly, and doesn't need translation.
flyWebPublishServer.ask=Would you like to let this site start a server accessible to nearby devices and people?
# LOCALIZATION NOTE (flyWebPublishServer.dontAskAgain): This is an experimental feature only shipping in Nightly, and doesn't need translation.
flyWebPublishServer.dontAskAgain=Don't ask again for this site
# LOCALIZATION NOTE (flyWebPublishServer.publishServer): This is an experimental feature only shipping in Nightly, and doesn't need translation.
flyWebPublishServer.publishServer=Publish Server
# Imageblocking
imageblocking.downloadedImage=Image unblocked
imageblocking.showAllImages=Show All