Backed out changeset 920775ddfb85 (bug 1044736)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 12 Nov 2014 08:39:32 +0100
changeset 215299 42d8dd6707a6e64daf36ec1f72b9ac5b769ef7e4
parent 215298 c0e01ea4dd3d1fcaeae01f611c1cffb46726f368
child 215300 0c51ff222a400936ec0f4179c2126d2889389683
push id51731
push userryanvm@gmail.com
push dateWed, 12 Nov 2014 20:52:34 +0000
treeherdermozilla-inbound@90731dbaab2d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1044736
milestone36.0a1
backs out920775ddfb85bebc35d2b65f60ad41069516dd0c
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
Backed out changeset 920775ddfb85 (bug 1044736)
dom/apps/tests/file_test_widget.js
dom/apps/tests/mochitest.ini
dom/apps/tests/test_widget.html
dom/apps/tests/test_widget_browser.html
dom/html/nsBrowserElement.cpp
dom/html/nsBrowserElement.h
dom/html/nsGenericHTMLFrameElement.cpp
--- a/dom/apps/tests/file_test_widget.js
+++ b/dom/apps/tests/file_test_widget.js
@@ -1,12 +1,11 @@
 var gWidgetManifestURL = 'http://test/tests/dom/apps/tests/file_app.sjs?apptype=widget&getmanifest=true';
 var gInvalidWidgetManifestURL = 'http://test/tests/dom/apps/tests/file_app.sjs?apptype=invalidWidget&getmanifest=true';
 var gApp;
-var gHasBrowserPermission;
 
 function onError() {
   ok(false, "Error callback invoked");
   finish();
 }
 
 function installApp(path) {
   var request = navigator.mozApps.install(path);
@@ -78,44 +77,31 @@ function testApp(isValidWidget) {
     ifr.addEventListener(topic, function() {
       ok(false, topic + " should be hidden");
     }, false);
   });
 }
 
 function testLimitedBrowserAPI(ifr) {
   var securitySensitiveCalls = [
-    { api: 'sendMouseEvent'      , args: ['mousedown', 0, 0, 0, 0, 0] },
-    { api: 'sendTouchEvent'      , args: ['touchstart', [0], [0], [0], [1], [1], [0], [1], 1, 0] },
-    { api: 'goBack'              , args: [] },
-    { api: 'goForward'           , args: [] },
-    { api: 'reload'              , args: [] },
-    { api: 'stop'                , args: [] },
-    { api: 'download'            , args: ['http://example.org'] },
-    { api: 'purgeHistory'        , args: [] },
-    { api: 'getScreenshot'       , args: [0, 0] },
-    { api: 'zoom'                , args: [0.1] },
-    { api: 'getCanGoBack'        , args: [] },
-    { api: 'getCanGoForward'     , args: [] },
-    { api: 'getContentDimensions', args: [] }
+    'sendMouseEvent',
+    'sendTouchEvent',
+    'goBack',
+    'goForward',
+    'reload',
+    'stop',
+    'download',
+    'purgeHistory',
+    'getScreenshot',
+    'zoom',
+    'getCanGoBack',
+    'getCanGoForward'
   ];
   securitySensitiveCalls.forEach( function(call) {
-    if (gHasBrowserPermission) {
-      isnot(typeof ifr[call.api], "undefined", call.api + " should be defined");
-      var didThrow;
-      try {
-        ifr[call.api].apply(ifr, call.args);
-      } catch (e) {
-        ok(e instanceof DOMException, "throw right exception type");
-        didThrow = e.code;
-      }
-      is(didThrow, DOMException.INVALID_NODE_TYPE_ERR, "call " + call.api + " should throw exception");
-    } else {
-      is(typeof ifr[call.api], "undefined", call.api + " should be hidden for widget");
-    }
+    is(typeof ifr[call], "undefined", call + " should be hidden for widget");
   });
 }
 
 function loadFrameScript(mm) {
   var script = 'data:,\
   function ok(p, msg) { \
   if (p) { \
   sendAsyncMessage("OK", msg); \
@@ -163,17 +149,17 @@ function loadFrameScript(mm) {
   ';
   mm.loadFrameScript(script, /* allowDelayedLoad = */ false);
 }
 
 var tests = [
   // Permissions
   function() {
     SpecialPowers.pushPermissions(
-      [{ "type": "browser", "allow": gHasBrowserPermission ? 1 : 0, "context": document },
+      [{ "type": "browser", "allow": 1, "context": document },
        { "type": "embed-widgets", "allow": 1, "context": document },
        { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
   },
 
   // Preferences
   function() {
     SpecialPowers.pushPrefEnv({"set": [["dom.mozBrowserFramesEnabled", true],
                                        ["dom.enable_widgets", true],
--- a/dom/apps/tests/mochitest.ini
+++ b/dom/apps/tests/mochitest.ini
@@ -40,10 +40,8 @@ skip-if = (toolkit == 'android' && proce
 skip-if = (toolkit == 'android' && processor == 'x86') #x86 only
 [test_receipt_operations.html]
 [test_signed_pkg_install.html]
 [test_uninstall_errors.html]
 [test_theme_role.html]
 [test_web_app_install.html]
 [test_widget.html]
 skip-if = os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
-[test_widget_browser.html]
-skip-if = os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
--- a/dom/apps/tests/test_widget.html
+++ b/dom/apps/tests/test_widget.html
@@ -6,13 +6,12 @@
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="file_test_widget.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <div id="container"></div>
   <script type="application/javascript;version=1.7">
   SimpleTest.waitForExplicitFinish();
-  gHasBrowserPermission = false;
   runTest();
   </script>
 </body>
 </html>
deleted file mode 100644
--- a/dom/apps/tests/test_widget_browser.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test for DataStore - basic operation on a readonly db</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="file_test_widget.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<div id="container"></div>
-  <script type="application/javascript;version=1.7">
-  SimpleTest.waitForExplicitFinish();
-  gHasBrowserPermission = true;
-  runTest();
-  </script>
-</body>
-</html>
--- a/dom/html/nsBrowserElement.cpp
+++ b/dom/html/nsBrowserElement.cpp
@@ -106,49 +106,36 @@ nsBrowserElement::IsBrowserElementOrThro
 {
   if (mBrowserElementAPI) {
     return true;
   }
   aRv.Throw(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
   return false;
 }
 
-bool
-nsBrowserElement::IsNotWidgetOrThrow(ErrorResult& aRv)
-{
-  if (!mOwnerIsWidget) {
-    return true;
-  }
-  aRv.Throw(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
-  return false;
-}
-
 void
 nsBrowserElement::InitBrowserElementAPI()
 {
   bool isBrowserOrApp;
   nsCOMPtr<nsIFrameLoader> frameLoader = GetFrameLoader();
   NS_ENSURE_TRUE_VOID(frameLoader);
   nsresult rv = frameLoader->GetOwnerIsBrowserOrAppFrame(&isBrowserOrApp);
   NS_ENSURE_SUCCESS_VOID(rv);
-  rv = frameLoader->GetOwnerIsWidget(&mOwnerIsWidget);
-  NS_ENSURE_SUCCESS_VOID(rv);
 
   if (!isBrowserOrApp) {
     return;
   }
 
   mBrowserElementAPI = do_CreateInstance("@mozilla.org/dom/browser-element-api;1");
   if (mBrowserElementAPI) {
     mBrowserElementAPI->SetFrameLoader(frameLoader);
   }
 }
 
 nsBrowserElement::nsBrowserElement()
-  : mOwnerIsWidget(false)
 {
   mObserver = new BrowserShownObserver(this);
   mObserver->AddObserver();
 }
 
 nsBrowserElement::~nsBrowserElement()
 {
   mObserver->RemoveObserver();
@@ -215,17 +202,16 @@ nsBrowserElement::SendMouseEvent(const n
                                  uint32_t aX,
                                  uint32_t aY,
                                  uint32_t aButton,
                                  uint32_t aClickCount,
                                  uint32_t aModifiers,
                                  ErrorResult& aRv)
 {
   NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
-  NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
 
   nsresult rv = mBrowserElementAPI->SendMouseEvent(aType,
                                                    aX,
                                                    aY,
                                                    aButton,
                                                    aClickCount,
                                                    aModifiers);
 
@@ -243,17 +229,16 @@ nsBrowserElement::SendTouchEvent(const n
                                  const dom::Sequence<uint32_t>& aRys,
                                  const dom::Sequence<float>& aRotationAngles,
                                  const dom::Sequence<float>& aForces,
                                  uint32_t aCount,
                                  uint32_t aModifiers,
                                  ErrorResult& aRv)
 {
   NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
-  NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
 
   if (aIdentifiers.Length() != aCount ||
       aXs.Length() != aCount ||
       aYs.Length() != aCount ||
       aRxs.Length() != aCount ||
       aRys.Length() != aCount ||
       aRotationAngles.Length() != aCount ||
       aForces.Length() != aCount) {
@@ -276,71 +261,66 @@ nsBrowserElement::SendTouchEvent(const n
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
   }
 }
 
 void
 nsBrowserElement::GoBack(ErrorResult& aRv)
 {
   NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
-  NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
 
   nsresult rv = mBrowserElementAPI->GoBack();
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
   }
 }
 
 void
 nsBrowserElement::GoForward(ErrorResult& aRv)
 {
   NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
-  NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
 
   nsresult rv = mBrowserElementAPI->GoForward();
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
   }
 }
 
 void
 nsBrowserElement::Reload(bool aHardReload, ErrorResult& aRv)
 {
   NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
-  NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
 
   nsresult rv = mBrowserElementAPI->Reload(aHardReload);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
   }
 }
 
 void
 nsBrowserElement::Stop(ErrorResult& aRv)
 {
   NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
-  NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
 
   nsresult rv = mBrowserElementAPI->Stop();
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
   }
 }
 
 already_AddRefed<dom::DOMRequest>
 nsBrowserElement::Download(const nsAString& aUrl,
                            const dom::BrowserElementDownloadOptions& aOptions,
                            ErrorResult& aRv)
 {
   NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
-  NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
 
   nsCOMPtr<nsIDOMDOMRequest> req;
   AutoJSAPI jsapi;
   jsapi.Init();
   JS::Rooted<JS::Value> options(jsapi.cx());
   if (!ToJSValue(jsapi.cx(), aOptions, &options)) {
     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return nullptr;
@@ -354,17 +334,16 @@ nsBrowserElement::Download(const nsAStri
 
   return req.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<dom::DOMRequest>
 nsBrowserElement::PurgeHistory(ErrorResult& aRv)
 {
   NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
-  NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
 
   nsCOMPtr<nsIDOMDOMRequest> req;
   nsresult rv = mBrowserElementAPI->PurgeHistory(getter_AddRefs(req));
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
@@ -374,17 +353,16 @@ nsBrowserElement::PurgeHistory(ErrorResu
 
 already_AddRefed<dom::DOMRequest>
 nsBrowserElement::GetScreenshot(uint32_t aWidth,
                                 uint32_t aHeight,
                                 const nsAString& aMimeType,
                                 ErrorResult& aRv)
 {
   NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
-  NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
 
   nsCOMPtr<nsIDOMDOMRequest> req;
   nsresult rv = mBrowserElementAPI->GetScreenshot(aWidth, aHeight, aMimeType,
                                                   getter_AddRefs(req));
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     if (rv == NS_ERROR_INVALID_ARG) {
       aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
@@ -396,64 +374,59 @@ nsBrowserElement::GetScreenshot(uint32_t
 
   return req.forget().downcast<DOMRequest>();
 }
 
 void
 nsBrowserElement::Zoom(float aZoom, ErrorResult& aRv)
 {
   NS_ENSURE_TRUE_VOID(IsBrowserElementOrThrow(aRv));
-  NS_ENSURE_TRUE_VOID(IsNotWidgetOrThrow(aRv));
-
   nsresult rv = mBrowserElementAPI->Zoom(aZoom);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
   }
 }
 
 already_AddRefed<dom::DOMRequest>
 nsBrowserElement::GetCanGoBack(ErrorResult& aRv)
 {
   NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
-  NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
 
   nsCOMPtr<nsIDOMDOMRequest> req;
   nsresult rv = mBrowserElementAPI->GetCanGoBack(getter_AddRefs(req));
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
 
   return req.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<dom::DOMRequest>
 nsBrowserElement::GetCanGoForward(ErrorResult& aRv)
 {
   NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
-  NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
 
   nsCOMPtr<nsIDOMDOMRequest> req;
   nsresult rv = mBrowserElementAPI->GetCanGoForward(getter_AddRefs(req));
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
 
   return req.forget().downcast<DOMRequest>();
 }
 
 already_AddRefed<dom::DOMRequest>
 nsBrowserElement::GetContentDimensions(ErrorResult& aRv)
 {
   NS_ENSURE_TRUE(IsBrowserElementOrThrow(aRv), nullptr);
-  NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
 
   nsCOMPtr<nsIDOMDOMRequest> req;
   nsresult rv = mBrowserElementAPI->GetContentDimensions(getter_AddRefs(req));
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
--- a/dom/html/nsBrowserElement.h
+++ b/dom/html/nsBrowserElement.h
@@ -91,18 +91,16 @@ public:
 
 protected:
   virtual already_AddRefed<nsFrameLoader> GetFrameLoader() = 0;
   nsCOMPtr<nsIBrowserElementAPI> mBrowserElementAPI;
 
 private:
   void InitBrowserElementAPI();
   bool IsBrowserElementOrThrow(ErrorResult& aRv);
-  bool IsNotWidgetOrThrow(ErrorResult& aRv);
-  bool mOwnerIsWidget;
 
   class BrowserShownObserver;
   friend class BrowserShownObserver;
   nsRefPtr<BrowserShownObserver> mObserver;
 };
 
 } // namespace mozilla
 
--- a/dom/html/nsGenericHTMLFrameElement.cpp
+++ b/dom/html/nsGenericHTMLFrameElement.cpp
@@ -302,20 +302,16 @@ nsGenericHTMLFrameElement::GetReallyIsBr
   nsIPrincipal *principal = NodePrincipal();
   nsCOMPtr<nsIPermissionManager> permMgr =
     services::GetPermissionManager();
   NS_ENSURE_TRUE(permMgr, NS_OK);
 
   uint32_t permission = nsIPermissionManager::DENY_ACTION;
   nsresult rv = permMgr->TestPermissionFromPrincipal(principal, "browser", &permission);
   NS_ENSURE_SUCCESS(rv, NS_OK);
-  if (permission != nsIPermissionManager::ALLOW_ACTION) {
-    rv = permMgr->TestPermissionFromPrincipal(principal, "embed-widgets", &permission);
-    NS_ENSURE_SUCCESS(rv, NS_OK);
-  }
   *aOut = permission == nsIPermissionManager::ALLOW_ACTION;
   return NS_OK;
 }
 
 /* [infallible] */ NS_IMETHODIMP
 nsGenericHTMLFrameElement::GetReallyIsApp(bool *aOut)
 {
   nsAutoString manifestURL;