Bug 1416343 - Mark URI interfaces as [builtinclass] r=bagder draft
authorValentin Gosu <valentin.gosu@gmail.com>
Wed, 15 Nov 2017 13:34:23 +0100
changeset 698278 fa720f35df16985bcd929a98aeeaf9fbc759c1e6
parent 697757 b0a6b4678b2f7dfb499328946b95366775f71edd
child 740327 546af7c01c979d3d672334e6532980c367d7397b
push id89235
push uservalentin.gosu@gmail.com
push dateWed, 15 Nov 2017 12:36:02 +0000
reviewersbagder
bugs1416343
milestone59.0a1
Bug 1416343 - Mark URI interfaces as [builtinclass] r=bagder MozReview-Commit-ID: 4T0uCkHP1a6
browser/modules/test/browser/browser_SitePermissions_tab_urls.js
image/nsIIconURI.idl
modules/libjar/nsIJARURI.idl
netwerk/base/nsIFileURL.idl
netwerk/base/nsINestedURI.idl
netwerk/base/nsIStandardURL.idl
netwerk/base/nsIURI.idl
netwerk/base/nsIURIWithBlobImpl.idl
netwerk/base/nsIURIWithPrincipal.idl
netwerk/base/nsIURL.idl
netwerk/test/unit/test_bug365133.js
netwerk/test/unit/test_bug484684.js
netwerk/test/unit/test_bug515583.js
netwerk/test/unit/test_bug543805.js
--- a/browser/modules/test/browser/browser_SitePermissions_tab_urls.js
+++ b/browser/modules/test/browser/browser_SitePermissions_tab_urls.js
@@ -1,30 +1,41 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 Cu.import("resource:///modules/SitePermissions.jsm", this);
 
+function newURI(url) {
+  return Services.io.newURI(url);
+}
+
 // This tests the key used to store the URI -> permission map on a tab.
 add_task(async function testTemporaryPermissionTabURLs() {
 
   // Prevent showing a dialog for https://name:password@example.com
   SpecialPowers.pushPrefEnv({set: [
         ["network.http.phishy-userpass-length", 2048],
   ]});
 
   // This usually takes about 60 seconds on 32bit Linux debug,
   // due to the combinatory nature of the test that is hard to fix.
   requestLongerTimeout(2);
 
-  let same = [ "https://example.com", "https://example.com/sub/path", "https://example.com:443" ].map(Services.io.newURI);
-  let different = [ "https://example.com", "https://name:password@example.com", "https://test1.example.com", "http://example.com", "http://example.org" ].map(Services.io.newURI);
+
+  let same = [ newURI("https://example.com"),
+               newURI("https://example.com/sub/path"),
+               newURI("https://example.com:443") ]
+  let different = [ newURI("https://example.com"),
+                    newURI("https://name:password@example.com"),
+                    newURI("https://test1.example.com"),
+                    newURI("http://example.com"),
+                    newURI("http://example.org") ]
 
   let id = "microphone";
 
   await BrowserTestUtils.withNewTab("about:blank", async function(browser) {
     for (let uri of same) {
         let loaded = BrowserTestUtils.browserLoaded(browser, false, uri.spec);
         browser.loadURI(uri.spec);
         await loaded;
--- a/image/nsIIconURI.idl
+++ b/image/nsIIconURI.idl
@@ -40,17 +40,17 @@
    *   Description: The state of the icon.
    *
    *   Parameter:   contentType
    *   Values:      <mime-type>
    *   Description: The mime type we want an icon for. This is ignored by
    *                stock images.
    */
 
-[scriptable, uuid(f8fe5ef2-5f2b-43f3-857d-5b64d192c427)]
+[scriptable, builtinclass, uuid(f8fe5ef2-5f2b-43f3-857d-5b64d192c427)]
 interface nsIMozIconURI : nsIURI
 {
   /// iconFile: the file URL contained within this moz-icon url, or null.
   attribute nsIURL iconURL;
 
   /// imageSize: The image area in square pixels, defaults to 16 if unspecified.
   attribute unsigned long imageSize;
 
--- a/modules/libjar/nsIJARURI.idl
+++ b/modules/libjar/nsIJARURI.idl
@@ -10,17 +10,17 @@
  * JAR URLs have the following syntax
  *
  * jar:<jar-file-uri>!/<jar-entry>
  *
  * EXAMPLE: jar:http://www.big.com/blue.jar!/ocean.html
  *
  * The nsIURL methods operate on the <jar-entry> part of the spec.
  */
-[scriptable, uuid(646a508c-f786-4e14-be6d-8dda2a633c60)]
+[scriptable, builtinclass, uuid(646a508c-f786-4e14-be6d-8dda2a633c60)]
 interface nsIJARURI : nsIURL {
 
     /**
      * Returns the root URI (the one for the actual JAR file) for this JAR
      * (e.g., http://www.big.com/blue.jar).
      */
     readonly attribute nsIURI JARFile;
 
--- a/netwerk/base/nsIFileURL.idl
+++ b/netwerk/base/nsIFileURL.idl
@@ -7,17 +7,17 @@
 
 interface nsIFile;
 
 /**
  * nsIFileURL provides access to the underlying nsIFile object corresponding to
  * an URL.  The URL scheme need not be file:, since other local protocols may
  * map URLs to files (e.g., resource:).
  */
-[scriptable, uuid(e91ac988-27c2-448b-b1a1-3822e1ef1987)]
+[scriptable, builtinclass, uuid(e91ac988-27c2-448b-b1a1-3822e1ef1987)]
 interface nsIFileURL : nsIURL
 {
     /**
      * Get/Set nsIFile corresponding to this URL.
      *
      *  - Getter returns a reference to an immutable object.  Callers must clone
      *    before attempting to modify the returned nsIFile object.  NOTE: this
      *    constraint might not be enforced at runtime, so beware!!
--- a/netwerk/base/nsINestedURI.idl
+++ b/netwerk/base/nsINestedURI.idl
@@ -16,17 +16,17 @@ interface nsIURI;
  *
  *   sanitize:http://example.com
  *
  * and opening a channel on such a sanitize: URI gets the data from
  * http://example.com, sanitizes it, and returns it, then the sanitize: URI
  * should implement nsINestedURI and return the http://example.com URI as its
  * inner URI.
  */
-[scriptable, uuid(6de2c874-796c-46bf-b57f-0d7bd7d6cab0)]
+[scriptable, builtinclass, uuid(6de2c874-796c-46bf-b57f-0d7bd7d6cab0)]
 interface nsINestedURI : nsISupports
 {
   /**
    * The inner URI for this nested URI.  This must not return null if the
    * getter succeeds; URIs that have no inner must not QI to this interface.
    * Dynamically changing whether there is an inner URI is not allowed.
    *
    * Modifying the returned URI must not in any way modify the nested URI; this
--- a/netwerk/base/nsIStandardURL.idl
+++ b/netwerk/base/nsIStandardURL.idl
@@ -8,17 +8,17 @@
 interface nsIURI;
 
 /**
  * nsIStandardURL defines the interface to an URL with the standard
  * file path format common to protocols like http, ftp, and file.
  * It supports initialization from a relative path and provides
  * some customization on how URLs are normalized.
  */
-[scriptable, uuid(babd6cca-ebe7-4329-967c-d6b9e33caa81)]
+[scriptable, builtinclass, uuid(babd6cca-ebe7-4329-967c-d6b9e33caa81)]
 interface nsIStandardURL : nsIMutable
 {
     /**
      * blah:foo/bar    => blah://foo/bar
      * blah:/foo/bar   => blah:///foo/bar
      * blah://foo/bar  => blah://foo/bar
      * blah:///foo/bar => blah:///foo/bar
      */
--- a/netwerk/base/nsIURI.idl
+++ b/netwerk/base/nsIURI.idl
@@ -66,17 +66,17 @@ class Encoding;
  * nsIIOService.newURI.
  *
  * NOTE: nsBinaryInputStream::ReadObject contains a hackaround to intercept the
  * old (pre-gecko6) nsIURI IID and swap in the current IID instead, in order
  * for sessionstore to work after an upgrade.  If this IID is revved further,
  * we will need to add additional checks there for all intermediate IIDs, until
  * ContentPrincipal is fixed to serialize its URIs as nsISupports (bug 662693).
  */
-[scriptable, uuid(92073a54-6d78-4f30-913a-b871813208c6)]
+[scriptable, builtinclass, uuid(92073a54-6d78-4f30-913a-b871813208c6)]
 interface nsIURI : nsISupports
 {
     /************************************************************************
      * The URI is broken down into the following principal components:
      */
 
     /**
      * Returns a string representation of the URI. Setting the spec causes
--- a/netwerk/base/nsIURIWithBlobImpl.idl
+++ b/netwerk/base/nsIURIWithBlobImpl.idl
@@ -5,16 +5,16 @@
 #include "nsISupports.idl"
 
 interface nsIURI;
 
 /**
  * nsIURIWithBlobImpl is implemented by URIs which are associated with a
  * specific BlobImpl.
  */
-[builtinclass, uuid(331b41d3-3506-4ab5-bef9-aab41e3202a3)]
+[builtinclass, builtinclass, uuid(331b41d3-3506-4ab5-bef9-aab41e3202a3)]
 interface nsIURIWithBlobImpl : nsISupports
 {
     /**
      * The BlobImpl associated with the resource returned when loading this uri.
      */
     readonly attribute nsISupports blobImpl;
 };
--- a/netwerk/base/nsIURIWithPrincipal.idl
+++ b/netwerk/base/nsIURIWithPrincipal.idl
@@ -6,17 +6,17 @@
 
 interface nsIPrincipal;
 interface nsIURI;
 
 /**
  * nsIURIWithPrincipal is implemented by URIs which are associated with a
  * specific principal.
  */
-[scriptable, uuid(626a5c0c-bfd8-4531-8b47-a8451b0daa33)]
+[scriptable, builtinclass, uuid(626a5c0c-bfd8-4531-8b47-a8451b0daa33)]
 interface nsIURIWithPrincipal : nsISupports
 {
     /**
      * The principal associated with the resource returned when loading this
      * uri.
      */
     readonly attribute nsIPrincipal principal;
 
--- a/netwerk/base/nsIURL.idl
+++ b/netwerk/base/nsIURL.idl
@@ -14,17 +14,17 @@
  *            \          \                       /
  *             \          -----------------------
  *              \                   |          /
  *               \               fileName     /
  *                ----------------------------
  *                            |
  *                        filePath
  */
-[scriptable, uuid(86adcd89-0b70-47a2-b0fe-5bb2c5f37e31)]
+[scriptable, builtinclass, uuid(86adcd89-0b70-47a2-b0fe-5bb2c5f37e31)]
 interface nsIURL : nsIURI
 {
     /*************************************************************************
      * The URL path is broken down into the following principal components:
      *
      * attribute AUTF8String filePath;
      * attribute AUTF8String query;
      *
--- a/netwerk/test/unit/test_bug365133.js
+++ b/netwerk/test/unit/test_bug365133.js
@@ -1,9 +1,10 @@
 const URL = "ftp://localhost/bug365133/";
+Cu.import("resource://gre/modules/NetUtil.jsm");
 
 const tests = [
   [ /* Unix style listing, space at the end of filename */
     "drwxrwxr-x    2 500      500          4096 Jan 01  2000 a \r\n"
   ,
     "300: " + URL + "\n" +
     "200: filename content-length last-modified file-type\n" +
     "201: \"a%20\" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 DIRECTORY \n"
@@ -70,21 +71,17 @@ function storeData() {
             getService(Ci.nsIStreamConverterService);
   var converter = scs.asyncConvertData("text/ftp-dir", "application/http-index-format",
                                        new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null);
 
   var stream = Cc["@mozilla.org/io/string-input-stream;1"].
                createInstance(Ci.nsIStringInputStream);
   stream.data = tests[0][0];
 
-  var url = {
-    password: "",
-    asciiSpec: URL,
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIURI])
-  };
+  var url = NetUtil.newURI(URL);
 
   var channel = {
     URI: url,
     contentLength: -1,
     pending: true,
     isPending: function() {
       return this.pending;
     },
--- a/netwerk/test/unit/test_bug484684.js
+++ b/netwerk/test/unit/test_bug484684.js
@@ -1,9 +1,10 @@
 const URL = "ftp://localhost/bug464884/";
+Cu.import("resource://gre/modules/NetUtil.jsm");
 
 const tests = [
   // standard ls unix format
   ["-rw-rw-r--    1 500      500             0 Jan 01  2000 file1\r\n" +
    "-rw-rw-r--    1 500      500             0 Jan 01  2000  file2\r\n",
 
    "300: " + URL + "\n" +
    "200: filename content-length last-modified file-type\n" +
@@ -74,21 +75,17 @@ function storeData(status, entry) {
             getService(Ci.nsIStreamConverterService);
   var converter = scs.asyncConvertData("text/ftp-dir", "application/http-index-format",
                                        new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null);
 
   var stream = Cc["@mozilla.org/io/string-input-stream;1"].
                createInstance(Ci.nsIStringInputStream);
   stream.data = tests[0][0];
 
-  var url = {
-    password: "",
-    asciiSpec: URL,
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIURI])
-  };
+  var url = NetUtil.newURI(URL);
 
   var channel = {
     URI: url,
     contentLength: -1,
     pending: true,
     isPending: function() {
       return this.pending;
     },
--- a/netwerk/test/unit/test_bug515583.js
+++ b/netwerk/test/unit/test_bug515583.js
@@ -1,9 +1,10 @@
 const URL = "ftp://localhost/bug515583/";
+Cu.import("resource://gre/modules/NetUtil.jsm");
 
 const tests = [
   ["[RWCEM1 4 1-MAR-1993 18:09:01.12\r\n" +
    "[RWCEM1] 4 2-MAR-1993 18:09:01.12\r\n" +
    "[RWCEM1]A 4 3-MAR-1993 18:09:01.12\r\n" +
    "[RWCEM1]B; 4 4-MAR-1993 18:09:01.12\r\n" +
    "[RWCEM1];1 4 5-MAR-1993 18:09:01.12\r\n" +
    "[RWCEM1]; 4 6-MAR-1993 18:09:01.12\r\n" +
@@ -32,21 +33,17 @@ function storeData(status, entry) {
             getService(Ci.nsIStreamConverterService);
   var converter = scs.asyncConvertData("text/ftp-dir", "application/http-index-format",
                                        new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null);
 
   var stream = Cc["@mozilla.org/io/string-input-stream;1"].
                createInstance(Ci.nsIStringInputStream);
   stream.data = tests[0][0];
 
-  var url = {
-    password: "",
-    asciiSpec: URL,
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIURI])
-  };
+  var url = NetUtil.newURI(URL);
 
   var channel = {
     URI: url,
     contentLength: -1,
     pending: true,
     isPending: function() {
       return this.pending;
     },
--- a/netwerk/test/unit/test_bug543805.js
+++ b/netwerk/test/unit/test_bug543805.js
@@ -1,9 +1,10 @@
 const URL = "ftp://localhost/bug543805/";
+Cu.import("resource://gre/modules/NetUtil.jsm");
 
 var dayNames = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
 var year = new Date().getFullYear().toString();
 var day = dayNames[new Date(year, 0, 1).getDay()];
 
 const tests = [
   // AIX ls format
   ["-rw-r--r--   1 0                11 Jan  1 20:19  nodup.file\r\n" +
@@ -52,21 +53,17 @@ function storeData(status, entry) {
             getService(Ci.nsIStreamConverterService);
   var converter = scs.asyncConvertData("text/ftp-dir", "application/http-index-format",
                                        new ChannelListener(checkData, null, CL_ALLOW_UNKNOWN_CL), null);
 
   var stream = Cc["@mozilla.org/io/string-input-stream;1"].
                createInstance(Ci.nsIStringInputStream);
   stream.data = tests[0][0];
 
-  var url = {
-    password: "",
-    asciiSpec: URL,
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIURI])
-  };
+  var url = NetUtil.newURI(URL);
 
   var channel = {
     URI: url,
     contentLength: -1,
     pending: true,
     isPending: function() {
       return this.pending;
     },