【问题标题】:Privileged App won't run in Firefox OS Simulator特权应用程序无法在 Firefox OS Simulator 中运行
【发布时间】:2014-03-13 10:41:14
【问题描述】:

我目前正在为 Firefox OS 开发我的第一个应用程序,并且我正在使用模拟器进行开发,因为我没有真正的硬件。
对于我的应用,我需要 redirects 权限(用于使用 OAuth),因此它需要获得特权。
只要我不将"type": "privileged" 添加到应用程序的清单中,我的应用程序(或实际完成的部分)就可以正常工作。如果我这样做,我的整个 JS 代码将不再运行(包括简单的事件监听器)。我已经在 Aurora 的 App-Manager 中使用 FFOS 1.2 和 1.3 模拟器测试了该行为,并且开发工具上没有输出。
你能帮帮我吗?

这是清单:

{  
  "default_locale": "en",  
  "description": "Feed the Reader is a free and open-source RSS-Reader. It works as a standalone app and with Feedly, The Old Reader and Tiny Tiny RSS as well.",  
  "developer": {  
    "name": "Philipp Trommler",  
    "url": ""  
  },  
  "icons": {  
    "16": "/icons/ftr_16.png",  
    "32": "/icons/ftr_32.png",  
    "48": "/icons/ftr_48.png",  
    "60": "/icons/ftr_60.png",  
    "64": "/icons/ftr_64.png",  
    "128": "/icons/ftr_128.png"  
  },  
  "launch_path": "/app.html",  
  "name": "Feed the Reader",  
  "permissions": {  
    "browser": {  
      "description": "Used for OAuth authentication."  
    },  
    "systemXHR": {  
      "description": "Used for asynchronous loading."  
    }  
  },  
  "redirects": [  
    {"from": "http://localhost",  
     "to": "/redirects.html"}  
  ],  
  "type": "privileged",  
  "version": "1.0"  
}

【问题讨论】:

    标签: javascript html web-applications firefox-os


    【解决方案1】:

    这对我有用。

      "type": "privileged",
      "permissions": {
        "storage": {
          "description": "Required to store podcast audio files and images."
        },
        "systemXHR": {
          "description": "Required to download podcasts."
        },
        "contacts": {
          "description": "Required for autocompletion in the share screen",
          "access": "readcreate"
        }   
      }
    

    【讨论】:

      【解决方案2】:

      我认为您的问题与清单无关。您是否在 HTML 中内联运行任何脚本?它可能由于 CSP 违规而失败。将所有 js 移动到外部 js 库并使用自调用函数 (function(){})() 或类似 window.init 的东西来加载和运行您正在内联执行的代码。查看 Firefox OS Boilerplate 以获取使用自调用函数的示例。 https://github.com/robnyman/Firefox-OS-Boilerplate-App

      【讨论】:

        【解决方案3】:

        感谢您的回复!

        我的 Javascript 中有错字,但没有显示在调试控制台中,甚至没有加载该文件。我不得不重命名它,然后控制台给了我错误,所以我可以修复它。现在文件再次加载,即使它是旧名称......奇怪,但没关系。
        我不明白为什么模拟器控制台与普通控制台不同,但显然它是,因为后者给了我更多的信息和警告。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2014-11-07
          • 2014-12-16
          • 1970-01-01
          • 2013-05-23
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多