WebAPI/WidgetAPI: Difference between revisions

Prevent Pages to Be Embedded {{bug|1043110}}
(Prevent Pages to Be Embedded {{bug|1043110}})
 
(26 intermediate revisions by 3 users not shown)
Line 12: Line 12:
     widgets: {
     widgets: {
       "mywidget1": {
       "mywidget1": {
         name: "MyApp2000 Widget",
         "name": "MyApp2000 Widget",
         href: "/widget.html",
         "launch_path": "/widget.html",
         description: "This is my cool widget",
         "description": "This is my cool widget",
         screenshot: "foo.jpg"
         "preview_image": "foo.jpg",
        "locales": {
          "en-US": {
            "launch_path": "/widget_en-US.html",
            "name":"MyApp2000 Widget",
            "description":"This is my cool widget",
            "preview_image": "foo_en-US.jpg"
          }
        }
       },
       },
       "myotherwidget": { ... }
       "myotherwidget": { ... }
     }
     },
     widgetPages: [
     widgetPages: [
       "/widget.html",
       "/widget.html",
      "/widget_en-US.html",
       "/news_reader_settings.html",
       "/news_reader_settings.html",
       "/some_other_page.html"
       "/some_other_page.html"
     ]
     ]
    "locales": {
      "en-US": {
        "name" : "MyApp2000",
        "discription":"Cool App",
        "widgets": {
          "mywidget1": {
            "name":"MyApp2000 Widget",
            "description":"This is my cool widget"
          },
          "myotherwidget": { ... }
        }
      }
    }
   }
   }
==== Manifest with Entry Points ====
For some app with entry_points declared, we still use "widgets" field at the top level of manifest to decouple the relationship between entry points and widgets.
==== Localization of Widget Info ====
Similar to app's localization, the localization of widget MUST be embedded in its declaration.


=== embed-widgets {{bug|1005818}} ===
=== embed-widgets {{bug|1005818}} ===
In order to expose to privileged APPs and consider security issue.
In order to expose to privileged APPs and consider security issue.


* "embed-widgets" is a new permission for "mozapp" attribute, it comes from [https://developer.mozilla.org/en-US/Apps/Build/App_permissions#embed-apps 'embed-apps'] but is more restricted. Please refer to [https://wiki.mozilla.org/WebAPI/WidgetAPI#Browser_API next section].
* "embed-widgets" is a new permission for "mozwidget" attribute, it is similar to [https://developer.mozilla.org/en-US/Apps/Build/App_permissions#embed-apps 'embed-apps'] but is more restricted. Please refer to [https://wiki.mozilla.org/WebAPI/WidgetAPI#Browser_API next section].
* Set manifest entry in "widget" attribute.   
* Set manifest entry in "widget" attribute.   
   <iframe mozbrowser=“true" mozwidget="manifestURL" src=“widget.html” remote=“true”>  
   <iframe mozbrowser=“true" mozwidget="manifestURL" src=“widget.html” remote=“true”>  
Line 52: Line 55:


==== Restriction ====
==== Restriction ====
*Disallow SRC attribute.
*iframe SRC MUST BE one of widgetPages list.
*Disallow parts of security sensitive browser API
*Disallow parts of security sensitive browser API
*Ignore mozLockOrientation/mozUnlockOrientation
*Ignore mozLockOrientation/mozUnlockOrientation
==== examples ====
==== examples ====
*APP:
*APP:
Line 60: Line 64:


*Widget:
*Widget:
**Disallow “src" attribute.
   <iframe mozbrowser=“true" mozwidget=“manifestURL” remote=“true” src=”widgetURL”>  
   <iframe mozbrowser=“true" mozapp=“manifestURL" widget=“widgetEntry” remote=“true”>  


*Open Bookmark:
*Open Bookmark:
Line 67: Line 70:
   <iframe mozbrowser=“true" remote="true" src="http://example.com">
   <iframe mozbrowser=“true" remote="true" src="http://example.com">


==Issues under discussion==
=== Prevent Pages to Be Embedded {{bug|1043110}} ===
Widgets' pages MUST be listed in "widgetPages" field which is the white list of widget pages. All pages in this list can be accessed through widget iframe. Others are shown as error pages, including other app pages and external pages. If the widget frame's src points to a page which is NOT listed in widgetPages,
*for existing app page: show NS_ERROR_MALFORMED_URI
*for missing app page: show NS_ERROR_MALFORMED_URI
*for external web page: show NS_ERROR_MALFORMED_URI
 
=== Other Notes ===
==== The Timing of Granting Permissions and Limiting Browser API ====
All permissions and the browser APIs are granted at iframe attached to DOM tree. Once done, Gecko creates/finds a process for this widget and associates them. The permissions and APIs are defined at that time. There is nothing happened when embedder tries to remove the mozwidget attribute or swap mozwidget to mozapp after that. If embedder removes mozwidget and changes the src, iframe still follows the widgetPages rule to check it.
 
==Limited Browser API==
===[https://developer.mozilla.org/zh-TW/docs/WebAPI/Browser#.E5.AD.98.E5.8F.96_%28Navigation%29_.E5.87.BD.E5.BC.8F Browser API]===
===[https://developer.mozilla.org/zh-TW/docs/WebAPI/Browser#.E5.AD.98.E5.8F.96_%28Navigation%29_.E5.87.BD.E5.BC.8F Browser API]===
Need to clarify which methods/Events are safe or unsafe.
Need to clarify which methods/Events are safe or unsafe.
Line 81: Line 94:


*Events
*Events
**mozbrowserasyncscroll
**mozbrowserclose
**mozbrowserclose
**mozbrowsererror
**mozbrowsererror
**mozbrowserloadend
**mozbrowserloadend
**mozbrowserloadstart
**mozbrowserloadstart
**mozbrowserfirstpaint
**mozbrowserdocumentfirstpaint


==== Security sensitive ====
==== Security sensitive ====
Line 104: Line 118:
**mozbrowsertitlechange - discloses title, privacy issue.
**mozbrowsertitlechange - discloses title, privacy issue.
**mozbrowseropensearch - I assume this discloses the link value, maybe a privacy issue?
**mozbrowseropensearch - I assume this discloses the link value, maybe a privacy issue?
**mozbrowsermanifestchange
**mozbrowsermetachange


=== no use case ===
=== no use case ===
Line 115: Line 131:
*Performance methods
*Performance methods
**<strike>purgeHistory()</strike>
**<strike>purgeHistory()</strike>
*Events
**<strike>mozbrowserasyncscroll</strike>
**<strike>mozbrowserresize</strike>
**<strike>mozbrowseractivitydone</strike>
**<strike>mozbrowserscroll</strike>


==Q&A==
==Q&A==
* Why we don't use 'src' to specify launch path?
** A security concern: widget embedder may embed a file which is not allowed by widget to be opened in widget mode.
* Why we need an app to explicitly expose its widget view? Is there any use case that an app doesn't want to be opened as a widget?
* Why we need an app to explicitly expose its widget view? Is there any use case that an app doesn't want to be opened as a widget?
** The app thinks its function can't be performed in widget mode, like lockscreen app or camera app.
** The app thinks its function can't be performed in widget mode, like lockscreen app or camera app.
** Just doesn't want itself to be embeded by other apps for various concerns, like Facebook app or bank apps.
** Just doesn't want itself to be embeded by other apps for various concerns, like Facebook app or bank apps.
* So I can't specify a 'src', how to open a bookmarked web page as a widget?  Web pages don't have a manifest to expose its widget view.
** No, you can't. We don't have a better solution for "initially" loading a 'http://' path within a widget. However, the topic is under discussion, we are trying to find out a solution.


* Is it possible to navigate to an external link within a widget?
* Is it possible to navigate to an external link within a widget?
** It should be fine to navigate an external link within a widget because window.location is changed by widget itself under its window context, not caused by the widget embedder.
** It should be fine to navigate an external link within a widget because window.location is changed by widget itself under its window context, not caused by the widget embedder.
** A widget is also an iframe. It follows "X-Frame-Options" restrictions. If a web page declare X-Frame-Options, the widget cannot shows that page.


* May a widget request to enlarge itself to full screen as its app mode?
* May a widget request to enlarge itself to full screen as its app mode?
Line 136: Line 152:
** We may introduce an attribute in manifest which tells widget embedder how to process the enlarging behavior. But we have to discuss it with Web API team.
** We may introduce an attribute in manifest which tells widget embedder how to process the enlarging behavior. But we have to discuss it with Web API team.


* What happens when embedder removes the mozwidget attribute of existing iframe?
** Nothing. We still follows the widget API rules to manage the iframe, the limited APIs and the same permissions.
* What happens when embedder uses mozapp originally and swap it as mozwidget?
** Nothing. We still follows the mozapp API rules to manage the iframe, the full-set browser API and the same permissions.
* What happens when embedder removes the mozwidget and changes the src of an existing iframe?
** Nothing. We still follows the widget API rules. If the src is in widgetPages, nothing happens. If the src is not in widgetPages, an error is emitted NS_ERROR_DOM_INVALID_ACCESS_ERR or NS_ERROR_FILE_NOT_FOUND.


==Bugs==
==Bugs==
* {{bug|1005818}} A new 'embed-widgets' permission exposing to privileged apps for solving widget case.
* <del>{{bug|1005818}}</del> A new 'embed-widgets' permission exposing to privileged apps for solving widget case.
** Part1: Add permission "embed-widgets" and HTMLIFrameElement attribute "mozWidget"
** Part 1: Load a widget as an app if the |src| is in the |widgetPages|
** Part2: Implementation of checking if a window is able to embed a specific widget.
** Part 2: Only limited browser API are available to a widget
** Part3: Enable to embed a widget if preconditions hold
 
** Part4: Only limited browser API are available to a widget
* {{bug|1043110}}  an appropriate way to prevent forbidden pages to be embedded in a widget iframe
* {{bug|1052328}}  Let privileged apps be able to launch a widget via APP protocol URIs
* {{bug|1052334}}  create a function to retrieve preview image of widget
* {{bug|1053724}}  Prevent Widget Frame to Listen/Handle System Message
 
[[Category:Web APIs]]
Confirmed users
29

edits