From 37be5dc5be97c44cc2754b3ea65a6b9f077d3f50 Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Fri, 31 Jul 2015 12:28:06 +0800 Subject: [PATCH] Bug 1188639 - Fix typo in BrowserElement.webidl and add tests for it. r=yoshi,bz --- .../mochitest/browserElement_SetNFCFocus.js | 30 +++++++++++++++++++ .../mochitest/mochitest-oop.ini | 1 + dom/browser-element/mochitest/mochitest.ini | 2 ++ ...est_browserElement_inproc_SetNFCFocus.html | 13 ++++++++ .../test_browserElement_oop_SetNFCFocus.html | 13 ++++++++ dom/webidl/BrowserElement.webidl | 2 +- 6 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 dom/browser-element/mochitest/browserElement_SetNFCFocus.js create mode 100644 dom/browser-element/mochitest/test_browserElement_inproc_SetNFCFocus.html create mode 100644 dom/browser-element/mochitest/test_browserElement_oop_SetNFCFocus.html diff --git a/dom/browser-element/mochitest/browserElement_SetNFCFocus.js b/dom/browser-element/mochitest/browserElement_SetNFCFocus.js new file mode 100644 index 000000000000..3332ca347e28 --- /dev/null +++ b/dom/browser-element/mochitest/browserElement_SetNFCFocus.js @@ -0,0 +1,30 @@ +/* Any copyright is dedicated to the public domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Bug 1188639 - Check permission to use setNFCFocus +"use strict"; + +SimpleTest.waitForExplicitFinish(); +browserElementTestHelpers.setEnabledPref(true); +browserElementTestHelpers.addPermission(); + +function hasSetNFCFocus() { + return new Promise((resolve, reject) => { + var iframe = document.createElement('iframe'); + iframe.setAttribute('mozbrowser', 'true'); + iframe.addEventListener('mozbrowserloadend', e => { + is(iframe.setNFCFocus !== undefined, true, + "has permission to use setNFCFocus"); + resolve(); + }); + document.body.appendChild(iframe); + }); +} + +function runTest() { + SpecialPowers.pushPermissions( + [{ 'type': 'nfc-manager', 'allow': 1, 'context': document }], + () => hasSetNFCFocus().then(SimpleTest.finish)); +} + +addEventListener('testready', runTest); diff --git a/dom/browser-element/mochitest/mochitest-oop.ini b/dom/browser-element/mochitest/mochitest-oop.ini index 3b7f81d7f022..657900d2b5ec 100644 --- a/dom/browser-element/mochitest/mochitest-oop.ini +++ b/dom/browser-element/mochitest/mochitest-oop.ini @@ -113,3 +113,4 @@ disabled = bug 924771 disabled = bug 924771 [test_browserElement_oop_GetContentDimensions.html] [test_browserElement_oop_AudioChannel.html] +[test_browserElement_oop_SetNFCFocus.html] diff --git a/dom/browser-element/mochitest/mochitest.ini b/dom/browser-element/mochitest/mochitest.ini index f7ebd1304d16..cff492fb7d77 100644 --- a/dom/browser-element/mochitest/mochitest.ini +++ b/dom/browser-element/mochitest/mochitest.ini @@ -61,6 +61,7 @@ support-files = browserElement_SendEvent.js browserElement_SelectionStateBlur.js browserElement_SetInputMethodActive.js + browserElement_SetNFCFocus.js browserElement_SetVisible.js browserElement_SetVisibleFrames.js browserElement_SetVisibleFrames2.js @@ -230,3 +231,4 @@ skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 936226 disabled = bug 774100 [test_browserElement_inproc_GetContentDimensions.html] [test_browserElement_inproc_AudioChannel.html] +[test_browserElement_inproc_SetNFCFocus.html] diff --git a/dom/browser-element/mochitest/test_browserElement_inproc_SetNFCFocus.html b/dom/browser-element/mochitest/test_browserElement_inproc_SetNFCFocus.html new file mode 100644 index 000000000000..a511c6d99fb4 --- /dev/null +++ b/dom/browser-element/mochitest/test_browserElement_inproc_SetNFCFocus.html @@ -0,0 +1,13 @@ + + + + Test for Bug 1188639 + + + + + + + + diff --git a/dom/browser-element/mochitest/test_browserElement_oop_SetNFCFocus.html b/dom/browser-element/mochitest/test_browserElement_oop_SetNFCFocus.html new file mode 100644 index 000000000000..a511c6d99fb4 --- /dev/null +++ b/dom/browser-element/mochitest/test_browserElement_oop_SetNFCFocus.html @@ -0,0 +1,13 @@ + + + + Test for Bug 1188639 + + + + + + + + diff --git a/dom/webidl/BrowserElement.webidl b/dom/webidl/BrowserElement.webidl index da29edf8c1d3..72f88426170c 100644 --- a/dom/webidl/BrowserElement.webidl +++ b/dom/webidl/BrowserElement.webidl @@ -151,7 +151,7 @@ interface BrowserElementPrivileged { [Throws, Pref="dom.mozBrowserFramesEnabled", - CheckAllPermissions="browser setNFCFocus"] + CheckAllPermissions="browser nfc-manager"] void setNFCFocus(boolean isFocus); [Throws,