Bug 1242522 - [webext] Add WebNavigation's UrlFilter to the json schema. r=kmag draft
authorLuca Greco <lgreco@mozilla.com>
Tue, 07 Jun 2016 17:32:15 +0200
changeset 377468 47cb3dab0d08e8793ff9d76bb27ce8ea49e8254d
parent 377467 46791353267d6269ecca96b2df2e708f06415bde
child 377469 9d60fb0ae25115c1018292b09023c82a12e74107
push id20803
push userluca.greco@alcacoop.it
push dateFri, 10 Jun 2016 13:33:19 +0000
reviewerskmag
bugs1242522
milestone50.0a1
Bug 1242522 - [webext] Add WebNavigation's UrlFilter to the json schema. r=kmag web_navigation.json was using a custom "filter" attribute which seems to add an implicit optional extra parameter. As we already support a similar feature for the web_request.json, which declares the optional event filter as an explicit "extraParameters", which is already supported, this patch adds the "events.UrlFilter" definition and turns all the "filter" attributes into "extraParameters". MozReview-Commit-ID: IDKCkKV67xh
toolkit/components/extensions/schemas/web_navigation.json
--- a/toolkit/components/extensions/schemas/web_navigation.json
+++ b/toolkit/components/extensions/schemas/web_navigation.json
@@ -26,16 +26,27 @@
         "type": "string",
         "enum": ["link", "typed", "auto_bookmark", "auto_subframe", "manual_subframe", "generated", "start_page", "form_submit", "reload", "keyword", "keyword_generated"],
         "description": "Cause of the navigation. The same transition types as defined in the history API are used. These are the same transition types as defined in the $(topic:transition_types)[history API] except with <code>\"start_page\"</code> in place of <code>\"auto_toplevel\"</code> (for backwards compatibility)."
       },
       {
         "id": "TransitionQualifier",
         "type": "string",
         "enum": ["client_redirect", "server_redirect", "forward_back", "from_address_bar"]
+      },
+      {
+        "id": "EventUrlFilters",
+        "type": "object",
+        "properties": {
+          "url": {
+            "type": "array",
+            "minItems": 1,
+            "items": { "$ref": "events.UrlFilter" }
+          }
+        }
       }
     ],
     "functions": [
       {
         "name": "getFrame",
         "type": "function",
         "description": "Retrieves information about the given frame. A frame refers to an &lt;iframe&gt; or a &lt;frame&gt; of a web page and is identified by a tab ID and a frame ID.",
         "async": "callback",
@@ -135,200 +146,200 @@
         ]
       }
     ],
     "events": [
       {
         "name": "onBeforeNavigate",
         "type": "function",
         "description": "Fired when a navigation is about to occur.",
-        "filters": [
-          {
-            "name": "url",
-            "type": "array",
-            "items": { "$ref": "events.UrlFilter" },
-            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
-          }
-        ],
         "parameters": [
           {
             "type": "object",
             "name": "details",
             "properties": {
               "tabId": {"type": "integer", "description": "The ID of the tab in which the navigation is about to occur."},
               "url": {"type": "string"},
               "processId": {"unsupported": true, "type": "integer", "description": "The ID of the process runs the renderer for this tab."},
               "frameId": {"type": "integer", "description": "0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique for a given tab and process."},
               "parentFrameId": {"type": "integer", "description": "ID of frame that wraps the frame. Set to -1 of no parent frame exists."},
               "timeStamp": {"type": "number", "description": "The time when the browser was about to start the navigation, in milliseconds since the epoch."}
             }
           }
+        ],
+        "extraParameters": [
+          {
+            "name": "filters",
+            "optional": true,
+            "$ref": "EventUrlFilters",
+            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
+          }
         ]
       },
       {
         "name": "onCommitted",
         "type": "function",
         "description": "Fired when a navigation is committed. The document (and the resources it refers to, such as images and subframes) might still be downloading, but at least part of the document has been received from the server and the browser has decided to switch to the new document.",
-        "filters": [
-          {
-            "name": "url",
-            "type": "array",
-            "items": { "$ref": "events.UrlFilter" },
-            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
-          }
-        ],
         "parameters": [
           {
             "type": "object",
             "name": "details",
             "properties": {
               "tabId": {"type": "integer", "description": "The ID of the tab in which the navigation occurs."},
               "url": {"type": "string"},
               "processId": {"unsupported": true, "type": "integer", "description": "The ID of the process runs the renderer for this tab."},
               "frameId": {"type": "integer", "description": "0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab."},
               "transitionType": {"unsupported": true, "$ref": "TransitionType", "description": "Cause of the navigation."},
               "transitionQualifiers": {"unsupported": true, "type": "array", "description": "A list of transition qualifiers.", "items": {"$ref": "TransitionQualifier"}},
               "timeStamp": {"type": "number", "description": "The time when the navigation was committed, in milliseconds since the epoch."}
             }
           }
+        ],
+        "extraParameters": [
+          {
+            "name": "filters",
+            "optional": true,
+            "$ref": "EventUrlFilters",
+            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
+          }
         ]
       },
       {
         "name": "onDOMContentLoaded",
         "type": "function",
         "description": "Fired when the page's DOM is fully constructed, but the referenced resources may not finish loading.",
-        "filters": [
-          {
-            "name": "url",
-            "type": "array",
-            "items": { "$ref": "events.UrlFilter" },
-            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
-          }
-        ],
         "parameters": [
           {
             "type": "object",
             "name": "details",
             "properties": {
               "tabId": {"type": "integer", "description": "The ID of the tab in which the navigation occurs."},
               "url": {"type": "string"},
               "processId": {"unsupported": true, "type": "integer", "description": "The ID of the process runs the renderer for this tab."},
               "frameId": {"type": "integer", "description": "0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab."},
               "timeStamp": {"type": "number", "description": "The time when the page's DOM was fully constructed, in milliseconds since the epoch."}
             }
           }
+        ],
+        "extraParameters": [
+          {
+            "name": "filters",
+            "optional": true,
+            "$ref": "EventUrlFilters",
+            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
+          }
         ]
       },
       {
         "name": "onCompleted",
         "type": "function",
         "description": "Fired when a document, including the resources it refers to, is completely loaded and initialized.",
-        "filters": [
-          {
-            "name": "url",
-            "type": "array",
-            "items": { "$ref": "events.UrlFilter" },
-            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
-          }
-        ],
         "parameters": [
           {
             "type": "object",
             "name": "details",
             "properties": {
               "tabId": {"type": "integer", "description": "The ID of the tab in which the navigation occurs."},
               "url": {"type": "string"},
               "processId": {"unsupported": true, "type": "integer", "description": "The ID of the process runs the renderer for this tab."},
               "frameId": {"type": "integer", "description": "0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab."},
               "timeStamp": {"type": "number", "description": "The time when the document finished loading, in milliseconds since the epoch."}
             }
           }
+        ],
+        "extraParameters": [
+          {
+            "name": "filters",
+            "optional": true,
+            "$ref": "EventUrlFilters",
+            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
+          }
         ]
       },
       {
         "name": "onErrorOccurred",
         "type": "function",
         "description": "Fired when an error occurs and the navigation is aborted. This can happen if either a network error occurred, or the user aborted the navigation.",
-        "filters": [
-          {
-            "name": "url",
-            "type": "array",
-            "items": { "$ref": "events.UrlFilter" },
-            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
-          }
-        ],
         "parameters": [
           {
             "type": "object",
             "name": "details",
             "properties": {
               "tabId": {"type": "integer", "description": "The ID of the tab in which the navigation occurs."},
               "url": {"type": "string"},
               "processId": {"unsupported": true, "type": "integer", "description": "The ID of the process runs the renderer for this tab."},
               "frameId": {"type": "integer", "description": "0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab."},
               "error": {"unsupported": true, "type": "string", "description": "The error description."},
               "timeStamp": {"type": "number", "description": "The time when the error occurred, in milliseconds since the epoch."}
             }
           }
+        ],
+        "extraParameters": [
+          {
+            "name": "filters",
+            "optional": true,
+            "$ref": "EventUrlFilters",
+            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
+          }
         ]
       },
       {
         "name": "onCreatedNavigationTarget",
         "unsupported": true,
         "type": "function",
         "description": "Fired when a new window, or a new tab in an existing window, is created to host a navigation.",
-        "filters": [
-          {
-            "name": "url",
-            "type": "array",
-            "items": { "$ref": "events.UrlFilter" },
-            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
-          }
-        ],
         "parameters": [
           {
             "type": "object",
             "name": "details",
             "properties": {
               "sourceTabId": {"type": "integer", "description": "The ID of the tab in which the navigation is triggered."},
               "sourceProcessId": {"type": "integer", "description": "The ID of the process runs the renderer for the source tab."},
               "sourceFrameId": {"type": "integer", "description": "The ID of the frame with sourceTabId in which the navigation is triggered. 0 indicates the main frame."},
               "url": {"type": "string", "description": "The URL to be opened in the new window."},
               "tabId": {"type": "integer", "description": "The ID of the tab in which the url is opened"},
               "timeStamp": {"type": "number", "description": "The time when the browser was about to create a new view, in milliseconds since the epoch."}
             }
           }
+        ],
+        "extraParameters": [
+          {
+            "name": "filters",
+            "optional": true,
+            "$ref": "EventUrlFilters",
+            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
+          }
         ]
       },
       {
         "name": "onReferenceFragmentUpdated",
         "type": "function",
         "description": "Fired when the reference fragment of a frame was updated. All future events for that frame will use the updated URL.",
-        "filters": [
-          {
-            "name": "url",
-            "type": "array",
-            "items": { "$ref": "events.UrlFilter" },
-            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
-          }
-        ],
         "parameters": [
           {
             "type": "object",
             "name": "details",
             "properties": {
               "tabId": {"type": "integer", "description": "The ID of the tab in which the navigation occurs."},
               "url": {"type": "string"},
               "processId": {"unsupported": true, "type": "integer", "description": "The ID of the process runs the renderer for this tab."},
               "frameId": {"type": "integer", "description": "0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab."},
               "transitionType": {"unsupported": true, "$ref": "TransitionType", "description": "Cause of the navigation."},
               "transitionQualifiers": {"unsupported": true, "type": "array", "description": "A list of transition qualifiers.", "items": {"$ref": "TransitionQualifier"}},
               "timeStamp": {"type": "number", "description": "The time when the navigation was committed, in milliseconds since the epoch."}
             }
           }
+        ],
+        "extraParameters": [
+          {
+            "name": "filters",
+            "optional": true,
+            "$ref": "EventUrlFilters",
+            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
+          }
         ]
       },
       {
         "name": "onTabReplaced",
         "unsupported": true,
         "type": "function",
         "description": "Fired when the contents of the tab is replaced by a different (usually previously pre-rendered) tab.",
         "parameters": [
@@ -342,35 +353,35 @@
             }
           }
         ]
       },
       {
         "name": "onHistoryStateUpdated",
         "type": "function",
         "description": "Fired when the frame's history was updated to a new URL. All future events for that frame will use the updated URL.",
-        "filters": [
-          {
-            "name": "url",
-            "type": "array",
-            "items": { "$ref": "events.UrlFilter" },
-            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
-          }
-        ],
         "parameters": [
           {
             "type": "object",
             "name": "details",
             "properties": {
               "tabId": {"type": "integer", "description": "The ID of the tab in which the navigation occurs."},
               "url": {"type": "string"},
               "processId": {"unsupported": true, "type": "integer", "description": "The ID of the process runs the renderer for this tab."},
               "frameId": {"type": "integer", "description": "0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab."},
               "transitionType": {"unsupported": true, "$ref": "TransitionType", "description": "Cause of the navigation."},
               "transitionQualifiers": {"unsupported": true, "type": "array", "description": "A list of transition qualifiers.", "items": {"$ref": "TransitionQualifier"}},
               "timeStamp": {"type": "number", "description": "The time when the navigation was committed, in milliseconds since the epoch."}
             }
           }
+        ],
+        "extraParameters": [
+          {
+            "name": "filters",
+            "optional": true,
+            "$ref": "EventUrlFilters",
+            "description": "Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event."
+          }
         ]
       }
     ]
   }
 ]