Bug 1105827 - Part 1: Add stub PermissionStatus implementation. r=baku
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Tue, 28 Jul 2015 06:33:46 -0700
changeset 286605 d03882fd396cee9d9590fef6ba3963545c918c61
parent 286604 0582b7cd205221437730cb6ff4f2aab57e4da50a
child 286606 adf77961b36065eebfd73ec4d60f76280fbdfd42
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1105827
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1105827 - Part 1: Add stub PermissionStatus implementation. r=baku
dom/permission/PermissionStatus.cpp
dom/permission/PermissionStatus.h
dom/permission/moz.build
dom/tests/mochitest/general/test_interfaces.html
dom/webidl/PermissionStatus.webidl
dom/webidl/moz.build
modules/libpref/init/all.js
new file mode 100644
--- /dev/null
+++ b/dom/permission/PermissionStatus.cpp
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 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/. */
+
+#include "mozilla/dom/PermissionStatus.h"
+#include "mozilla/Services.h"
+
+#include "nsIPermissionManager.h"
+
+namespace mozilla {
+namespace dom {
+
+PermissionStatus::PermissionStatus(nsPIDOMWindow* aWindow,
+                                   PermissionState aState)
+  : DOMEventTargetHelper(aWindow)
+  , mState(aState)
+{
+}
+
+PermissionStatus::~PermissionStatus()
+{
+}
+
+JSObject*
+PermissionStatus::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
+{
+  return PermissionStatusBinding::Wrap(aCx, this, aGivenProto);
+}
+
+} // namespace dom
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/dom/permission/PermissionStatus.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 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/. */
+
+#ifndef mozilla_dom_PermissionStatus_h_
+#define mozilla_dom_PermissionStatus_h_
+
+#include "mozilla/dom/PermissionStatusBinding.h"
+#include "mozilla/DOMEventTargetHelper.h"
+
+namespace mozilla {
+namespace dom {
+
+class PermissionStatus final
+  : public DOMEventTargetHelper
+{
+public:
+  explicit PermissionStatus(nsPIDOMWindow* aWindow, PermissionState aState);
+
+  JSObject* WrapObject(JSContext* aCx,
+                       JS::Handle<JSObject*> aGivenProto) override;
+
+  PermissionState State() const { return mState; }
+
+  IMPL_EVENT_HANDLER(change)
+
+private:
+  ~PermissionStatus();
+
+  PermissionState mState;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_permissionstatus_h_
--- a/dom/permission/moz.build
+++ b/dom/permission/moz.build
@@ -1,14 +1,22 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
+EXPORTS.mozilla.dom += [
+    'PermissionStatus.h',
+]
+
+UNIFIED_SOURCES += [
+    'PermissionStatus.cpp',
+]
+
 EXTRA_COMPONENTS += [
     'PermissionPromptService.js',
     'PermissionPromptService.manifest',
     'PermissionSettings.js',
     'PermissionSettings.manifest',
 ]
 
 EXTRA_JS_MODULES += [
@@ -28,8 +36,12 @@ if CONFIG['MOZ_B2G_FM']:
 if CONFIG['MOZ_B2G_BT']:
     MOCHITEST_MANIFESTS += ['tests/mochitest-bt.ini']
 
 if CONFIG['MOZ_WEBSMS_BACKEND']:
     MOCHITEST_MANIFESTS += ['tests/mochitest-websms.ini']
 
 if CONFIG['MOZ_TIME_MANAGER']:
     MOCHITEST_MANIFESTS += ['tests/mochitest-time.ini']
+
+FAIL_ON_WARNINGS = True
+
+FINAL_LIBRARY = 'xul'
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -889,16 +889,18 @@ var interfaceNamesInGlobalScope =
     "PerformanceResourceTiming",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "PerformanceTiming",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "PeriodicWave",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "PermissionSettings", b2g: true, permission: ["permissions"]},
 // IMPORTANT: Do not change this list without review from a DOM peer!
+    {name: "PermissionStatus", nightly: true},
+// IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "PhoneNumberService", permission: ["phonenumberservice"]},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "Plugin",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "PluginArray",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "PointerEvent", nightly: true, desktop: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
new file mode 100644
--- /dev/null
+++ b/dom/webidl/PermissionStatus.webidl
@@ -0,0 +1,21 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/.
+ *
+ * The origin of this IDL file is
+ * https://w3c.github.io/permissions/#status-of-a-permission
+ */
+
+enum PermissionState {
+  "granted",
+  "denied",
+  "prompt"
+};
+
+[Exposed=(Window),
+ Pref="dom.permissions.enabled"]
+interface PermissionStatus : EventTarget {
+  readonly attribute PermissionState state;
+  attribute EventHandler onchange;
+};
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -350,16 +350,17 @@ WEBIDL_FILES = [
     'PerformanceEntry.webidl',
     'PerformanceMark.webidl',
     'PerformanceMeasure.webidl',
     'PerformanceNavigation.webidl',
     'PerformanceResourceTiming.webidl',
     'PerformanceTiming.webidl',
     'PeriodicWave.webidl',
     'PermissionSettings.webidl',
+    'PermissionStatus.webidl',
     'PhoneNumberService.webidl',
     'Plugin.webidl',
     'PluginArray.webidl',
     'PointerEvent.webidl',
     'PopupBoxObject.webidl',
     'Position.webidl',
     'PositionError.webidl',
     'PresentationDeviceInfoManager.webidl',
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -119,16 +119,23 @@ pref("dom.indexedDB.enabled", true);
 pref("dom.indexedDB.experimental", false);
 // Enable indexedDB logging.
 pref("dom.indexedDB.logging.enabled", true);
 // Detailed output in log messages.
 pref("dom.indexedDB.logging.details", true);
 // Enable profiler marks for indexedDB events.
 pref("dom.indexedDB.logging.profiler-marks", false);
 
+// Whether or not the Permissions API is enabled.
+#ifdef NIGHTLY_BUILD
+pref("dom.permissions.enabled", true);
+#else
+pref("dom.permissions.enabled", false);
+#endif
+
 // Whether or not Web Workers are enabled.
 pref("dom.workers.enabled", true);
 // The number of workers per domain allowed to run concurrently.
 pref("dom.workers.maxPerDomain", 20);
 
 // Whether or not Shared Web Workers are enabled.
 pref("dom.workers.sharedWorkers.enabled", true);