Bug 794407 - Web Activites should only be started by a user interaction. r=fabrice a=blocking-basecamp

This commit is contained in:
Mounir Lamouri 2012-11-15 19:06:49 +00:00
Родитель 904540f41d
Коммит 4984f8063e
1 изменённых файлов: 9 добавлений и 0 удалений

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

@ -6,6 +6,7 @@
#include "nsDOMClassInfo.h" #include "nsDOMClassInfo.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsIDOMActivityOptions.h" #include "nsIDOMActivityOptions.h"
#include "nsEventStateManager.h"
using namespace mozilla::dom; using namespace mozilla::dom;
@ -47,6 +48,14 @@ Activity::Initialize(nsISupports* aOwner,
Init(window); Init(window);
if (!nsEventStateManager::IsHandlingUserInput()) {
nsCOMPtr<nsIDOMRequestService> rs =
do_GetService("@mozilla.org/dom/dom-request-service;1");
rs->FireErrorAsync(static_cast<DOMRequest*>(this),
NS_LITERAL_STRING("NotUserInput"));
return NS_OK;
}
// We expect a single argument, which is a nsIDOMMozActivityOptions. // We expect a single argument, which is a nsIDOMMozActivityOptions.
if (aArgc != 1 || !aArgv[0].isObject()) { if (aArgc != 1 || !aArgv[0].isObject()) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;