Bug 1518051 [wpt PR 14732] - Refactor device_manager.mojom, a=testonly
authorFergus Dall <sidereal@google.com>
Thu, 31 Jan 2019 15:45:18 +0000
changeset 457888 424661ad59d3c1ac94612e09fe4ba49f03830354
parent 457887 ca63445325791cf135acce8310880f47d558f3c0
child 457889 e38a87ea1142063446fd7d8bd3e192ecff9aa0fe
push id35518
push useropoprus@mozilla.com
push dateFri, 08 Feb 2019 09:55:14 +0000
treeherdermozilla-central@3a3e393396f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1518051, 14732, 1350417, 891381, 1396009, 620603
milestone67.0a1
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
Bug 1518051 [wpt PR 14732] - Refactor device_manager.mojom, a=testonly Automatic update from web-platform-tests Refactor device_manager.mojom This CL will allow us to avoid including device_manager.mojom in web_usb_service.mojom, which will in turn all us to use file.mojom in DeviceManager without needing to add it to third_party/blink/web_tests/external/wpt/resources/chromium/ See also https://chromium-review.googlesource.com/c/chromium/src/+/1350417 Change-Id: Ib838c3b2321f62e9c66b927891481c96c12bbcdc Bug: 891381 Reviewed-on: https://chromium-review.googlesource.com/c/1396009 Reviewed-by: Reilly Grant <reillyg@chromium.org> Reviewed-by: Dominick Ng <dominickn@chromium.org> Commit-Queue: Fergus Dall <sidereal@google.com> Cr-Commit-Position: refs/heads/master@{#620603} -- wpt-commits: ba3622aa0057c5e58a3a014e370e165328617a55 wpt-pr: 14732
testing/web-platform/tests/resources/chromium/big_buffer.mojom.js
testing/web-platform/tests/resources/chromium/big_buffer.mojom.js.headers
testing/web-platform/tests/resources/chromium/device.mojom.js
testing/web-platform/tests/resources/chromium/device_enumeration_options.mojom.js
testing/web-platform/tests/resources/chromium/device_enumeration_options.mojom.js.headers
testing/web-platform/tests/resources/chromium/device_manager.mojom.js
testing/web-platform/tests/resources/chromium/device_manager.mojom.js.headers
testing/web-platform/tests/resources/chromium/device_manager_client.mojom.js
testing/web-platform/tests/resources/chromium/device_manager_client.mojom.js.headers
testing/web-platform/tests/resources/chromium/mojo_bindings.js
testing/web-platform/tests/resources/chromium/string16.mojom.js
testing/web-platform/tests/resources/chromium/url.mojom.js
testing/web-platform/tests/resources/chromium/web_usb_service.mojom.js
testing/web-platform/tests/webusb/resources/usb-helpers.js
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/resources/chromium/big_buffer.mojom.js
@@ -0,0 +1,263 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+'use strict';
+
+(function() {
+  var mojomId = 'mojo/public/mojom/base/big_buffer.mojom';
+  if (mojo.internal.isMojomLoaded(mojomId)) {
+    console.warn('The following mojom is loaded multiple times: ' + mojomId);
+    return;
+  }
+  mojo.internal.markMojomLoaded(mojomId);
+  var bindings = mojo;
+  var associatedBindings = mojo;
+  var codec = mojo.internal;
+  var validator = mojo.internal;
+
+  var exports = mojo.internal.exposeNamespace('mojoBase.mojom');
+
+
+
+  function BigBufferSharedMemoryRegion(values) {
+    this.initDefaults_();
+    this.initFields_(values);
+  }
+
+
+  BigBufferSharedMemoryRegion.prototype.initDefaults_ = function() {
+    this.bufferHandle = null;
+    this.size = 0;
+  };
+  BigBufferSharedMemoryRegion.prototype.initFields_ = function(fields) {
+    for(var field in fields) {
+        if (this.hasOwnProperty(field))
+          this[field] = fields[field];
+    }
+  };
+
+  BigBufferSharedMemoryRegion.validate = function(messageValidator, offset) {
+    var err;
+    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
+    if (err !== validator.validationError.NONE)
+        return err;
+
+    var kVersionSizes = [
+      {version: 0, numBytes: 16}
+    ];
+    err = messageValidator.validateStructVersion(offset, kVersionSizes);
+    if (err !== validator.validationError.NONE)
+        return err;
+
+
+    // validate BigBufferSharedMemoryRegion.bufferHandle
+    err = messageValidator.validateHandle(offset + codec.kStructHeaderSize + 0, false)
+    if (err !== validator.validationError.NONE)
+        return err;
+
+
+    return validator.validationError.NONE;
+  };
+
+  BigBufferSharedMemoryRegion.encodedSize = codec.kStructHeaderSize + 8;
+
+  BigBufferSharedMemoryRegion.decode = function(decoder) {
+    var packed;
+    var val = new BigBufferSharedMemoryRegion();
+    var numberOfBytes = decoder.readUint32();
+    var version = decoder.readUint32();
+    val.bufferHandle = decoder.decodeStruct(codec.Handle);
+    val.size = decoder.decodeStruct(codec.Uint32);
+    return val;
+  };
+
+  BigBufferSharedMemoryRegion.encode = function(encoder, val) {
+    var packed;
+    encoder.writeUint32(BigBufferSharedMemoryRegion.encodedSize);
+    encoder.writeUint32(0);
+    encoder.encodeStruct(codec.Handle, val.bufferHandle);
+    encoder.encodeStruct(codec.Uint32, val.size);
+  };
+
+  function BigBuffer(value) {
+    this.initDefault_();
+    this.initValue_(value);
+  }
+
+
+  BigBuffer.Tags = {
+    bytes: 0,
+    sharedMemory: 1,
+    invalidBuffer: 2,
+  };
+
+  BigBuffer.prototype.initDefault_ = function() {
+    this.$data = null;
+    this.$tag = undefined;
+  }
+
+  BigBuffer.prototype.initValue_ = function(value) {
+    if (value == undefined) {
+      return;
+    }
+
+    var keys = Object.keys(value);
+    if (keys.length == 0) {
+      return;
+    }
+
+    if (keys.length > 1) {
+      throw new TypeError("You may set only one member on a union.");
+    }
+
+    var fields = [
+        "bytes",
+        "sharedMemory",
+        "invalidBuffer",
+    ];
+
+    if (fields.indexOf(keys[0]) < 0) {
+      throw new ReferenceError(keys[0] + " is not a BigBuffer member.");
+
+    }
+
+    this[keys[0]] = value[keys[0]];
+  }
+  Object.defineProperty(BigBuffer.prototype, "bytes", {
+    get: function() {
+      if (this.$tag != BigBuffer.Tags.bytes) {
+        throw new ReferenceError(
+            "BigBuffer.bytes is not currently set.");
+      }
+      return this.$data;
+    },
+
+    set: function(value) {
+      this.$tag = BigBuffer.Tags.bytes;
+      this.$data = value;
+    }
+  });
+  Object.defineProperty(BigBuffer.prototype, "sharedMemory", {
+    get: function() {
+      if (this.$tag != BigBuffer.Tags.sharedMemory) {
+        throw new ReferenceError(
+            "BigBuffer.sharedMemory is not currently set.");
+      }
+      return this.$data;
+    },
+
+    set: function(value) {
+      this.$tag = BigBuffer.Tags.sharedMemory;
+      this.$data = value;
+    }
+  });
+  Object.defineProperty(BigBuffer.prototype, "invalidBuffer", {
+    get: function() {
+      if (this.$tag != BigBuffer.Tags.invalidBuffer) {
+        throw new ReferenceError(
+            "BigBuffer.invalidBuffer is not currently set.");
+      }
+      return this.$data;
+    },
+
+    set: function(value) {
+      this.$tag = BigBuffer.Tags.invalidBuffer;
+      this.$data = value;
+    }
+  });
+
+
+    BigBuffer.encode = function(encoder, val) {
+      if (val == null) {
+        encoder.writeUint64(0);
+        encoder.writeUint64(0);
+        return;
+      }
+      if (val.$tag == undefined) {
+        throw new TypeError("Cannot encode unions with an unknown member set.");
+      }
+
+      encoder.writeUint32(16);
+      encoder.writeUint32(val.$tag);
+      switch (val.$tag) {
+        case BigBuffer.Tags.bytes:
+          encoder.encodeArrayPointer(codec.Uint8, val.bytes);
+          break;
+        case BigBuffer.Tags.sharedMemory:
+          encoder.encodeStructPointer(BigBufferSharedMemoryRegion, val.sharedMemory);
+          break;
+        case BigBuffer.Tags.invalidBuffer:
+          encoder.writeUint8(val.invalidBuffer ? 1 : 0);
+          break;
+      }
+      encoder.align();
+    };
+
+
+    BigBuffer.decode = function(decoder) {
+      var size = decoder.readUint32();
+      if (size == 0) {
+        decoder.readUint32();
+        decoder.readUint64();
+        return null;
+      }
+
+      var result = new BigBuffer();
+      var tag = decoder.readUint32();
+      switch (tag) {
+        case BigBuffer.Tags.bytes:
+          result.bytes = decoder.decodeArrayPointer(codec.Uint8);
+          break;
+        case BigBuffer.Tags.sharedMemory:
+          result.sharedMemory = decoder.decodeStructPointer(BigBufferSharedMemoryRegion);
+          break;
+        case BigBuffer.Tags.invalidBuffer:
+          result.invalidBuffer = decoder.readUint8() ? true : false;
+          break;
+      }
+      decoder.align();
+
+      return result;
+    };
+
+
+    BigBuffer.validate = function(messageValidator, offset) {
+      var size = messageValidator.decodeUnionSize(offset);
+      if (size != 16) {
+        return validator.validationError.INVALID_UNION_SIZE;
+      }
+
+      var tag = messageValidator.decodeUnionTag(offset);
+      var data_offset = offset + 8;
+      var err;
+      switch (tag) {
+        case BigBuffer.Tags.bytes:
+
+
+    // validate BigBuffer.bytes
+    err = messageValidator.validateArrayPointer(data_offset, 1, codec.Uint8, false, [0], 0);
+    if (err !== validator.validationError.NONE)
+        return err;
+          break;
+        case BigBuffer.Tags.sharedMemory:
+
+
+    // validate BigBuffer.sharedMemory
+    err = messageValidator.validateStructPointer(data_offset, BigBufferSharedMemoryRegion, false);
+    if (err !== validator.validationError.NONE)
+        return err;
+          break;
+        case BigBuffer.Tags.invalidBuffer:
+
+
+          break;
+      }
+
+      return validator.validationError.NONE;
+    };
+
+  BigBuffer.encodedSize = 16;
+  exports.BigBufferSharedMemoryRegion = BigBufferSharedMemoryRegion;
+  exports.BigBuffer = BigBuffer;
+})();
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/resources/chromium/big_buffer.mojom.js.headers
@@ -0,0 +1,1 @@
+Content-Type: text/javascript; charset=utf-8
\ No newline at end of file
--- a/testing/web-platform/tests/resources/chromium/device.mojom.js
+++ b/testing/web-platform/tests/resources/chromium/device.mojom.js
@@ -13,33 +13,35 @@
   mojo.internal.markMojomLoaded(mojomId);
   var bindings = mojo;
   var associatedBindings = mojo;
   var codec = mojo.internal;
   var validator = mojo.internal;
 
   var exports = mojo.internal.exposeNamespace('device.mojom');
   var string16$ =
-      mojo.internal.exposeNamespace('mojo.common.mojom');
+      mojo.internal.exposeNamespace('mojoBase.mojom');
   if (mojo.config.autoLoadMojomDeps) {
     mojo.internal.loadMojomIfNecessary(
         'mojo/public/mojom/base/string16.mojom', '../../../../mojo/public/mojom/base/string16.mojom.js');
   }
   var url$ =
       mojo.internal.exposeNamespace('url.mojom');
   if (mojo.config.autoLoadMojomDeps) {
     mojo.internal.loadMojomIfNecessary(
         'url/mojom/url.mojom', '../../../../url/mojom/url.mojom.js');
   }
 
 
   var UsbOpenDeviceError = {};
   UsbOpenDeviceError.OK = 0;
   UsbOpenDeviceError.ACCESS_DENIED = UsbOpenDeviceError.OK + 1;
   UsbOpenDeviceError.ALREADY_OPEN = UsbOpenDeviceError.ACCESS_DENIED + 1;
+  UsbOpenDeviceError.MIN_VALUE = 0,
+  UsbOpenDeviceError.MAX_VALUE = 2,
 
   UsbOpenDeviceError.isKnownEnumValue = function(value) {
     switch (value) {
     case 0:
     case 1:
     case 2:
       return true;
     }
@@ -51,16 +53,18 @@
     if (isExtensible || this.isKnownEnumValue(enumValue))
       return validator.validationError.NONE;
 
     return validator.validationError.UNKNOWN_ENUM_VALUE;
   };
   var UsbTransferDirection = {};
   UsbTransferDirection.INBOUND = 0;
   UsbTransferDirection.OUTBOUND = UsbTransferDirection.INBOUND + 1;
+  UsbTransferDirection.MIN_VALUE = 0,
+  UsbTransferDirection.MAX_VALUE = 1,
 
   UsbTransferDirection.isKnownEnumValue = function(value) {
     switch (value) {
     case 0:
     case 1:
       return true;
     }
     return false;
@@ -73,16 +77,18 @@
 
     return validator.validationError.UNKNOWN_ENUM_VALUE;
   };
   var UsbControlTransferType = {};
   UsbControlTransferType.STANDARD = 0;
   UsbControlTransferType.CLASS = UsbControlTransferType.STANDARD + 1;
   UsbControlTransferType.VENDOR = UsbControlTransferType.CLASS + 1;
   UsbControlTransferType.RESERVED = UsbControlTransferType.VENDOR + 1;
+  UsbControlTransferType.MIN_VALUE = 0,
+  UsbControlTransferType.MAX_VALUE = 3,
 
   UsbControlTransferType.isKnownEnumValue = function(value) {
     switch (value) {
     case 0:
     case 1:
     case 2:
     case 3:
       return true;
@@ -97,16 +103,18 @@
 
     return validator.validationError.UNKNOWN_ENUM_VALUE;
   };
   var UsbControlTransferRecipient = {};
   UsbControlTransferRecipient.DEVICE = 0;
   UsbControlTransferRecipient.INTERFACE = UsbControlTransferRecipient.DEVICE + 1;
   UsbControlTransferRecipient.ENDPOINT = UsbControlTransferRecipient.INTERFACE + 1;
   UsbControlTransferRecipient.OTHER = UsbControlTransferRecipient.ENDPOINT + 1;
+  UsbControlTransferRecipient.MIN_VALUE = 0,
+  UsbControlTransferRecipient.MAX_VALUE = 3,
 
   UsbControlTransferRecipient.isKnownEnumValue = function(value) {
     switch (value) {
     case 0:
     case 1:
     case 2:
     case 3:
       return true;
@@ -121,16 +129,18 @@
 
     return validator.validationError.UNKNOWN_ENUM_VALUE;
   };
   var UsbTransferType = {};
   UsbTransferType.CONTROL = 0;
   UsbTransferType.ISOCHRONOUS = UsbTransferType.CONTROL + 1;
   UsbTransferType.BULK = UsbTransferType.ISOCHRONOUS + 1;
   UsbTransferType.INTERRUPT = UsbTransferType.BULK + 1;
+  UsbTransferType.MIN_VALUE = 0,
+  UsbTransferType.MAX_VALUE = 3,
 
   UsbTransferType.isKnownEnumValue = function(value) {
     switch (value) {
     case 0:
     case 1:
     case 2:
     case 3:
       return true;
@@ -150,16 +160,18 @@
   UsbTransferStatus.TRANSFER_ERROR = UsbTransferStatus.COMPLETED + 1;
   UsbTransferStatus.TIMEOUT = UsbTransferStatus.TRANSFER_ERROR + 1;
   UsbTransferStatus.CANCELLED = UsbTransferStatus.TIMEOUT + 1;
   UsbTransferStatus.STALLED = UsbTransferStatus.CANCELLED + 1;
   UsbTransferStatus.DISCONNECT = UsbTransferStatus.STALLED + 1;
   UsbTransferStatus.BABBLE = UsbTransferStatus.DISCONNECT + 1;
   UsbTransferStatus.SHORT_PACKET = UsbTransferStatus.BABBLE + 1;
   UsbTransferStatus.PERMISSION_DENIED = UsbTransferStatus.SHORT_PACKET + 1;
+  UsbTransferStatus.MIN_VALUE = 0,
+  UsbTransferStatus.MAX_VALUE = 8,
 
   UsbTransferStatus.isKnownEnumValue = function(value) {
     switch (value) {
     case 0:
     case 1:
     case 2:
     case 3:
     case 4:
@@ -3644,9 +3656,9 @@
   exports.UsbControlTransferParams = UsbControlTransferParams;
   exports.UsbIsochronousPacket = UsbIsochronousPacket;
   exports.UsbDevice = UsbDevice;
   exports.UsbDevicePtr = UsbDevicePtr;
   exports.UsbDeviceAssociatedPtr = UsbDeviceAssociatedPtr;
   exports.UsbDeviceClient = UsbDeviceClient;
   exports.UsbDeviceClientPtr = UsbDeviceClientPtr;
   exports.UsbDeviceClientAssociatedPtr = UsbDeviceClientAssociatedPtr;
-})();
+})();
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/resources/chromium/device_enumeration_options.mojom.js
@@ -0,0 +1,184 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+'use strict';
+
+(function() {
+  var mojomId = 'device/usb/public/mojom/device_enumeration_options.mojom';
+  if (mojo.internal.isMojomLoaded(mojomId)) {
+    console.warn('The following mojom is loaded multiple times: ' + mojomId);
+    return;
+  }
+  mojo.internal.markMojomLoaded(mojomId);
+  var bindings = mojo;
+  var associatedBindings = mojo;
+  var codec = mojo.internal;
+  var validator = mojo.internal;
+
+  var exports = mojo.internal.exposeNamespace('device.mojom');
+  var string16$ =
+      mojo.internal.exposeNamespace('mojoBase.mojom');
+  if (mojo.config.autoLoadMojomDeps) {
+    mojo.internal.loadMojomIfNecessary(
+        'mojo/public/mojom/base/string16.mojom', '../../../../mojo/public/mojom/base/string16.mojom.js');
+  }
+
+
+
+  function UsbDeviceFilter(values) {
+    this.initDefaults_();
+    this.initFields_(values);
+  }
+
+
+  UsbDeviceFilter.prototype.initDefaults_ = function() {
+    this.hasVendorId = false;
+    this.hasProductId = false;
+    this.hasClassCode = false;
+    this.hasSubclassCode = false;
+    this.hasProtocolCode = false;
+    this.classCode = 0;
+    this.vendorId = 0;
+    this.productId = 0;
+    this.subclassCode = 0;
+    this.protocolCode = 0;
+    this.serialNumber = null;
+  };
+  UsbDeviceFilter.prototype.initFields_ = function(fields) {
+    for(var field in fields) {
+        if (this.hasOwnProperty(field))
+          this[field] = fields[field];
+    }
+  };
+
+  UsbDeviceFilter.validate = function(messageValidator, offset) {
+    var err;
+    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
+    if (err !== validator.validationError.NONE)
+        return err;
+
+    var kVersionSizes = [
+      {version: 0, numBytes: 24}
+    ];
+    err = messageValidator.validateStructVersion(offset, kVersionSizes);
+    if (err !== validator.validationError.NONE)
+        return err;
+
+
+
+
+
+
+
+
+
+
+
+
+    // validate UsbDeviceFilter.serialNumber
+    err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 8, string16$.String16, true);
+    if (err !== validator.validationError.NONE)
+        return err;
+
+    return validator.validationError.NONE;
+  };
+
+  UsbDeviceFilter.encodedSize = codec.kStructHeaderSize + 16;
+
+  UsbDeviceFilter.decode = function(decoder) {
+    var packed;
+    var val = new UsbDeviceFilter();
+    var numberOfBytes = decoder.readUint32();
+    var version = decoder.readUint32();
+    packed = decoder.readUint8();
+    val.hasVendorId = (packed >> 0) & 1 ? true : false;
+    val.hasProductId = (packed >> 1) & 1 ? true : false;
+    val.hasClassCode = (packed >> 2) & 1 ? true : false;
+    val.hasSubclassCode = (packed >> 3) & 1 ? true : false;
+    val.hasProtocolCode = (packed >> 4) & 1 ? true : false;
+    val.classCode = decoder.decodeStruct(codec.Uint8);
+    val.vendorId = decoder.decodeStruct(codec.Uint16);
+    val.productId = decoder.decodeStruct(codec.Uint16);
+    val.subclassCode = decoder.decodeStruct(codec.Uint8);
+    val.protocolCode = decoder.decodeStruct(codec.Uint8);
+    val.serialNumber = decoder.decodeStructPointer(string16$.String16);
+    return val;
+  };
+
+  UsbDeviceFilter.encode = function(encoder, val) {
+    var packed;
+    encoder.writeUint32(UsbDeviceFilter.encodedSize);
+    encoder.writeUint32(0);
+    packed = 0;
+    packed |= (val.hasVendorId & 1) << 0
+    packed |= (val.hasProductId & 1) << 1
+    packed |= (val.hasClassCode & 1) << 2
+    packed |= (val.hasSubclassCode & 1) << 3
+    packed |= (val.hasProtocolCode & 1) << 4
+    encoder.writeUint8(packed);
+    encoder.encodeStruct(codec.Uint8, val.classCode);
+    encoder.encodeStruct(codec.Uint16, val.vendorId);
+    encoder.encodeStruct(codec.Uint16, val.productId);
+    encoder.encodeStruct(codec.Uint8, val.subclassCode);
+    encoder.encodeStruct(codec.Uint8, val.protocolCode);
+    encoder.encodeStructPointer(string16$.String16, val.serialNumber);
+  };
+  function UsbEnumerationOptions(values) {
+    this.initDefaults_();
+    this.initFields_(values);
+  }
+
+
+  UsbEnumerationOptions.prototype.initDefaults_ = function() {
+    this.filters = null;
+  };
+  UsbEnumerationOptions.prototype.initFields_ = function(fields) {
+    for(var field in fields) {
+        if (this.hasOwnProperty(field))
+          this[field] = fields[field];
+    }
+  };
+
+  UsbEnumerationOptions.validate = function(messageValidator, offset) {
+    var err;
+    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
+    if (err !== validator.validationError.NONE)
+        return err;
+
+    var kVersionSizes = [
+      {version: 0, numBytes: 16}
+    ];
+    err = messageValidator.validateStructVersion(offset, kVersionSizes);
+    if (err !== validator.validationError.NONE)
+        return err;
+
+
+    // validate UsbEnumerationOptions.filters
+    err = messageValidator.validateArrayPointer(offset + codec.kStructHeaderSize + 0, 8, new codec.PointerTo(UsbDeviceFilter), false, [0], 0);
+    if (err !== validator.validationError.NONE)
+        return err;
+
+    return validator.validationError.NONE;
+  };
+
+  UsbEnumerationOptions.encodedSize = codec.kStructHeaderSize + 8;
+
+  UsbEnumerationOptions.decode = function(decoder) {
+    var packed;
+    var val = new UsbEnumerationOptions();
+    var numberOfBytes = decoder.readUint32();
+    var version = decoder.readUint32();
+    val.filters = decoder.decodeArrayPointer(new codec.PointerTo(UsbDeviceFilter));
+    return val;
+  };
+
+  UsbEnumerationOptions.encode = function(encoder, val) {
+    var packed;
+    encoder.writeUint32(UsbEnumerationOptions.encodedSize);
+    encoder.writeUint32(0);
+    encoder.encodeArrayPointer(new codec.PointerTo(UsbDeviceFilter), val.filters);
+  };
+  exports.UsbDeviceFilter = UsbDeviceFilter;
+  exports.UsbEnumerationOptions = UsbEnumerationOptions;
+})();
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/resources/chromium/device_enumeration_options.mojom.js.headers
@@ -0,0 +1,1 @@
+Content-Type: text/javascript; charset=utf-8
\ No newline at end of file
deleted file mode 100644
--- a/testing/web-platform/tests/resources/chromium/device_manager.mojom.js
+++ /dev/null
@@ -1,843 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-'use strict';
-
-(function() {
-  var mojomId = 'device/usb/public/mojom/device_manager.mojom';
-  if (mojo.internal.isMojomLoaded(mojomId)) {
-    console.warn('The following mojom is loaded multiple times: ' + mojomId);
-    return;
-  }
-  mojo.internal.markMojomLoaded(mojomId);
-  var bindings = mojo;
-  var associatedBindings = mojo;
-  var codec = mojo.internal;
-  var validator = mojo.internal;
-
-  var exports = mojo.internal.exposeNamespace('device.mojom');
-  var device$ =
-      mojo.internal.exposeNamespace('device.mojom');
-  if (mojo.config.autoLoadMojomDeps) {
-    mojo.internal.loadMojomIfNecessary(
-        'device/usb/public/mojom/device.mojom', 'device.mojom.js');
-  }
-  var string16$ =
-      mojo.internal.exposeNamespace('mojo.common.mojom');
-  if (mojo.config.autoLoadMojomDeps) {
-    mojo.internal.loadMojomIfNecessary(
-        'mojo/public/mojom/base/string16.mojom', '../../../../mojo/public/mojom/base/string16.mojom.js');
-  }
-
-
-
-  function UsbDeviceFilter(values) {
-    this.initDefaults_();
-    this.initFields_(values);
-  }
-
-
-  UsbDeviceFilter.prototype.initDefaults_ = function() {
-    this.hasVendorId = false;
-    this.hasProductId = false;
-    this.hasClassCode = false;
-    this.hasSubclassCode = false;
-    this.hasProtocolCode = false;
-    this.classCode = 0;
-    this.vendorId = 0;
-    this.productId = 0;
-    this.subclassCode = 0;
-    this.protocolCode = 0;
-    this.serialNumber = null;
-  };
-  UsbDeviceFilter.prototype.initFields_ = function(fields) {
-    for(var field in fields) {
-        if (this.hasOwnProperty(field))
-          this[field] = fields[field];
-    }
-  };
-
-  UsbDeviceFilter.validate = function(messageValidator, offset) {
-    var err;
-    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    var kVersionSizes = [
-      {version: 0, numBytes: 24}
-    ];
-    err = messageValidator.validateStructVersion(offset, kVersionSizes);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-
-
-
-
-
-
-
-
-
-
-
-    // validate UsbDeviceFilter.serialNumber
-    err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 8, string16$.String16, true);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    return validator.validationError.NONE;
-  };
-
-  UsbDeviceFilter.encodedSize = codec.kStructHeaderSize + 16;
-
-  UsbDeviceFilter.decode = function(decoder) {
-    var packed;
-    var val = new UsbDeviceFilter();
-    var numberOfBytes = decoder.readUint32();
-    var version = decoder.readUint32();
-    packed = decoder.readUint8();
-    val.hasVendorId = (packed >> 0) & 1 ? true : false;
-    val.hasProductId = (packed >> 1) & 1 ? true : false;
-    val.hasClassCode = (packed >> 2) & 1 ? true : false;
-    val.hasSubclassCode = (packed >> 3) & 1 ? true : false;
-    val.hasProtocolCode = (packed >> 4) & 1 ? true : false;
-    val.classCode = decoder.decodeStruct(codec.Uint8);
-    val.vendorId = decoder.decodeStruct(codec.Uint16);
-    val.productId = decoder.decodeStruct(codec.Uint16);
-    val.subclassCode = decoder.decodeStruct(codec.Uint8);
-    val.protocolCode = decoder.decodeStruct(codec.Uint8);
-    val.serialNumber = decoder.decodeStructPointer(string16$.String16);
-    return val;
-  };
-
-  UsbDeviceFilter.encode = function(encoder, val) {
-    var packed;
-    encoder.writeUint32(UsbDeviceFilter.encodedSize);
-    encoder.writeUint32(0);
-    packed = 0;
-    packed |= (val.hasVendorId & 1) << 0
-    packed |= (val.hasProductId & 1) << 1
-    packed |= (val.hasClassCode & 1) << 2
-    packed |= (val.hasSubclassCode & 1) << 3
-    packed |= (val.hasProtocolCode & 1) << 4
-    encoder.writeUint8(packed);
-    encoder.encodeStruct(codec.Uint8, val.classCode);
-    encoder.encodeStruct(codec.Uint16, val.vendorId);
-    encoder.encodeStruct(codec.Uint16, val.productId);
-    encoder.encodeStruct(codec.Uint8, val.subclassCode);
-    encoder.encodeStruct(codec.Uint8, val.protocolCode);
-    encoder.encodeStructPointer(string16$.String16, val.serialNumber);
-  };
-  function UsbEnumerationOptions(values) {
-    this.initDefaults_();
-    this.initFields_(values);
-  }
-
-
-  UsbEnumerationOptions.prototype.initDefaults_ = function() {
-    this.filters = null;
-  };
-  UsbEnumerationOptions.prototype.initFields_ = function(fields) {
-    for(var field in fields) {
-        if (this.hasOwnProperty(field))
-          this[field] = fields[field];
-    }
-  };
-
-  UsbEnumerationOptions.validate = function(messageValidator, offset) {
-    var err;
-    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    var kVersionSizes = [
-      {version: 0, numBytes: 16}
-    ];
-    err = messageValidator.validateStructVersion(offset, kVersionSizes);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-
-    // validate UsbEnumerationOptions.filters
-    err = messageValidator.validateArrayPointer(offset + codec.kStructHeaderSize + 0, 8, new codec.PointerTo(UsbDeviceFilter), false, [0], 0);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    return validator.validationError.NONE;
-  };
-
-  UsbEnumerationOptions.encodedSize = codec.kStructHeaderSize + 8;
-
-  UsbEnumerationOptions.decode = function(decoder) {
-    var packed;
-    var val = new UsbEnumerationOptions();
-    var numberOfBytes = decoder.readUint32();
-    var version = decoder.readUint32();
-    val.filters = decoder.decodeArrayPointer(new codec.PointerTo(UsbDeviceFilter));
-    return val;
-  };
-
-  UsbEnumerationOptions.encode = function(encoder, val) {
-    var packed;
-    encoder.writeUint32(UsbEnumerationOptions.encodedSize);
-    encoder.writeUint32(0);
-    encoder.encodeArrayPointer(new codec.PointerTo(UsbDeviceFilter), val.filters);
-  };
-  function UsbDeviceManager_GetDevices_Params(values) {
-    this.initDefaults_();
-    this.initFields_(values);
-  }
-
-
-  UsbDeviceManager_GetDevices_Params.prototype.initDefaults_ = function() {
-    this.options = null;
-  };
-  UsbDeviceManager_GetDevices_Params.prototype.initFields_ = function(fields) {
-    for(var field in fields) {
-        if (this.hasOwnProperty(field))
-          this[field] = fields[field];
-    }
-  };
-
-  UsbDeviceManager_GetDevices_Params.validate = function(messageValidator, offset) {
-    var err;
-    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    var kVersionSizes = [
-      {version: 0, numBytes: 16}
-    ];
-    err = messageValidator.validateStructVersion(offset, kVersionSizes);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-
-    // validate UsbDeviceManager_GetDevices_Params.options
-    err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 0, UsbEnumerationOptions, true);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    return validator.validationError.NONE;
-  };
-
-  UsbDeviceManager_GetDevices_Params.encodedSize = codec.kStructHeaderSize + 8;
-
-  UsbDeviceManager_GetDevices_Params.decode = function(decoder) {
-    var packed;
-    var val = new UsbDeviceManager_GetDevices_Params();
-    var numberOfBytes = decoder.readUint32();
-    var version = decoder.readUint32();
-    val.options = decoder.decodeStructPointer(UsbEnumerationOptions);
-    return val;
-  };
-
-  UsbDeviceManager_GetDevices_Params.encode = function(encoder, val) {
-    var packed;
-    encoder.writeUint32(UsbDeviceManager_GetDevices_Params.encodedSize);
-    encoder.writeUint32(0);
-    encoder.encodeStructPointer(UsbEnumerationOptions, val.options);
-  };
-  function UsbDeviceManager_GetDevices_ResponseParams(values) {
-    this.initDefaults_();
-    this.initFields_(values);
-  }
-
-
-  UsbDeviceManager_GetDevices_ResponseParams.prototype.initDefaults_ = function() {
-    this.results = null;
-  };
-  UsbDeviceManager_GetDevices_ResponseParams.prototype.initFields_ = function(fields) {
-    for(var field in fields) {
-        if (this.hasOwnProperty(field))
-          this[field] = fields[field];
-    }
-  };
-
-  UsbDeviceManager_GetDevices_ResponseParams.validate = function(messageValidator, offset) {
-    var err;
-    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    var kVersionSizes = [
-      {version: 0, numBytes: 16}
-    ];
-    err = messageValidator.validateStructVersion(offset, kVersionSizes);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-
-    // validate UsbDeviceManager_GetDevices_ResponseParams.results
-    err = messageValidator.validateArrayPointer(offset + codec.kStructHeaderSize + 0, 8, new codec.PointerTo(device$.UsbDeviceInfo), false, [0], 0);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    return validator.validationError.NONE;
-  };
-
-  UsbDeviceManager_GetDevices_ResponseParams.encodedSize = codec.kStructHeaderSize + 8;
-
-  UsbDeviceManager_GetDevices_ResponseParams.decode = function(decoder) {
-    var packed;
-    var val = new UsbDeviceManager_GetDevices_ResponseParams();
-    var numberOfBytes = decoder.readUint32();
-    var version = decoder.readUint32();
-    val.results = decoder.decodeArrayPointer(new codec.PointerTo(device$.UsbDeviceInfo));
-    return val;
-  };
-
-  UsbDeviceManager_GetDevices_ResponseParams.encode = function(encoder, val) {
-    var packed;
-    encoder.writeUint32(UsbDeviceManager_GetDevices_ResponseParams.encodedSize);
-    encoder.writeUint32(0);
-    encoder.encodeArrayPointer(new codec.PointerTo(device$.UsbDeviceInfo), val.results);
-  };
-  function UsbDeviceManager_GetDevice_Params(values) {
-    this.initDefaults_();
-    this.initFields_(values);
-  }
-
-
-  UsbDeviceManager_GetDevice_Params.prototype.initDefaults_ = function() {
-    this.guid = null;
-    this.deviceRequest = new bindings.InterfaceRequest();
-  };
-  UsbDeviceManager_GetDevice_Params.prototype.initFields_ = function(fields) {
-    for(var field in fields) {
-        if (this.hasOwnProperty(field))
-          this[field] = fields[field];
-    }
-  };
-
-  UsbDeviceManager_GetDevice_Params.validate = function(messageValidator, offset) {
-    var err;
-    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    var kVersionSizes = [
-      {version: 0, numBytes: 24}
-    ];
-    err = messageValidator.validateStructVersion(offset, kVersionSizes);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-
-    // validate UsbDeviceManager_GetDevice_Params.guid
-    err = messageValidator.validateStringPointer(offset + codec.kStructHeaderSize + 0, false)
-    if (err !== validator.validationError.NONE)
-        return err;
-
-
-    // validate UsbDeviceManager_GetDevice_Params.deviceRequest
-    err = messageValidator.validateInterfaceRequest(offset + codec.kStructHeaderSize + 8, false)
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    return validator.validationError.NONE;
-  };
-
-  UsbDeviceManager_GetDevice_Params.encodedSize = codec.kStructHeaderSize + 16;
-
-  UsbDeviceManager_GetDevice_Params.decode = function(decoder) {
-    var packed;
-    var val = new UsbDeviceManager_GetDevice_Params();
-    var numberOfBytes = decoder.readUint32();
-    var version = decoder.readUint32();
-    val.guid = decoder.decodeStruct(codec.String);
-    val.deviceRequest = decoder.decodeStruct(codec.InterfaceRequest);
-    decoder.skip(1);
-    decoder.skip(1);
-    decoder.skip(1);
-    decoder.skip(1);
-    return val;
-  };
-
-  UsbDeviceManager_GetDevice_Params.encode = function(encoder, val) {
-    var packed;
-    encoder.writeUint32(UsbDeviceManager_GetDevice_Params.encodedSize);
-    encoder.writeUint32(0);
-    encoder.encodeStruct(codec.String, val.guid);
-    encoder.encodeStruct(codec.InterfaceRequest, val.deviceRequest);
-    encoder.skip(1);
-    encoder.skip(1);
-    encoder.skip(1);
-    encoder.skip(1);
-  };
-  function UsbDeviceManager_SetClient_Params(values) {
-    this.initDefaults_();
-    this.initFields_(values);
-  }
-
-
-  UsbDeviceManager_SetClient_Params.prototype.initDefaults_ = function() {
-    this.client = new UsbDeviceManagerClientPtr();
-  };
-  UsbDeviceManager_SetClient_Params.prototype.initFields_ = function(fields) {
-    for(var field in fields) {
-        if (this.hasOwnProperty(field))
-          this[field] = fields[field];
-    }
-  };
-
-  UsbDeviceManager_SetClient_Params.validate = function(messageValidator, offset) {
-    var err;
-    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    var kVersionSizes = [
-      {version: 0, numBytes: 16}
-    ];
-    err = messageValidator.validateStructVersion(offset, kVersionSizes);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-
-    // validate UsbDeviceManager_SetClient_Params.client
-    err = messageValidator.validateInterface(offset + codec.kStructHeaderSize + 0, false);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    return validator.validationError.NONE;
-  };
-
-  UsbDeviceManager_SetClient_Params.encodedSize = codec.kStructHeaderSize + 8;
-
-  UsbDeviceManager_SetClient_Params.decode = function(decoder) {
-    var packed;
-    var val = new UsbDeviceManager_SetClient_Params();
-    var numberOfBytes = decoder.readUint32();
-    var version = decoder.readUint32();
-    val.client = decoder.decodeStruct(new codec.Interface(UsbDeviceManagerClientPtr));
-    return val;
-  };
-
-  UsbDeviceManager_SetClient_Params.encode = function(encoder, val) {
-    var packed;
-    encoder.writeUint32(UsbDeviceManager_SetClient_Params.encodedSize);
-    encoder.writeUint32(0);
-    encoder.encodeStruct(new codec.Interface(UsbDeviceManagerClientPtr), val.client);
-  };
-  function UsbDeviceManagerClient_OnDeviceAdded_Params(values) {
-    this.initDefaults_();
-    this.initFields_(values);
-  }
-
-
-  UsbDeviceManagerClient_OnDeviceAdded_Params.prototype.initDefaults_ = function() {
-    this.deviceInfo = null;
-  };
-  UsbDeviceManagerClient_OnDeviceAdded_Params.prototype.initFields_ = function(fields) {
-    for(var field in fields) {
-        if (this.hasOwnProperty(field))
-          this[field] = fields[field];
-    }
-  };
-
-  UsbDeviceManagerClient_OnDeviceAdded_Params.validate = function(messageValidator, offset) {
-    var err;
-    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    var kVersionSizes = [
-      {version: 0, numBytes: 16}
-    ];
-    err = messageValidator.validateStructVersion(offset, kVersionSizes);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-
-    // validate UsbDeviceManagerClient_OnDeviceAdded_Params.deviceInfo
-    err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 0, device$.UsbDeviceInfo, false);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    return validator.validationError.NONE;
-  };
-
-  UsbDeviceManagerClient_OnDeviceAdded_Params.encodedSize = codec.kStructHeaderSize + 8;
-
-  UsbDeviceManagerClient_OnDeviceAdded_Params.decode = function(decoder) {
-    var packed;
-    var val = new UsbDeviceManagerClient_OnDeviceAdded_Params();
-    var numberOfBytes = decoder.readUint32();
-    var version = decoder.readUint32();
-    val.deviceInfo = decoder.decodeStructPointer(device$.UsbDeviceInfo);
-    return val;
-  };
-
-  UsbDeviceManagerClient_OnDeviceAdded_Params.encode = function(encoder, val) {
-    var packed;
-    encoder.writeUint32(UsbDeviceManagerClient_OnDeviceAdded_Params.encodedSize);
-    encoder.writeUint32(0);
-    encoder.encodeStructPointer(device$.UsbDeviceInfo, val.deviceInfo);
-  };
-  function UsbDeviceManagerClient_OnDeviceRemoved_Params(values) {
-    this.initDefaults_();
-    this.initFields_(values);
-  }
-
-
-  UsbDeviceManagerClient_OnDeviceRemoved_Params.prototype.initDefaults_ = function() {
-    this.deviceInfo = null;
-  };
-  UsbDeviceManagerClient_OnDeviceRemoved_Params.prototype.initFields_ = function(fields) {
-    for(var field in fields) {
-        if (this.hasOwnProperty(field))
-          this[field] = fields[field];
-    }
-  };
-
-  UsbDeviceManagerClient_OnDeviceRemoved_Params.validate = function(messageValidator, offset) {
-    var err;
-    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    var kVersionSizes = [
-      {version: 0, numBytes: 16}
-    ];
-    err = messageValidator.validateStructVersion(offset, kVersionSizes);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-
-    // validate UsbDeviceManagerClient_OnDeviceRemoved_Params.deviceInfo
-    err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 0, device$.UsbDeviceInfo, false);
-    if (err !== validator.validationError.NONE)
-        return err;
-
-    return validator.validationError.NONE;
-  };
-
-  UsbDeviceManagerClient_OnDeviceRemoved_Params.encodedSize = codec.kStructHeaderSize + 8;
-
-  UsbDeviceManagerClient_OnDeviceRemoved_Params.decode = function(decoder) {
-    var packed;
-    var val = new UsbDeviceManagerClient_OnDeviceRemoved_Params();
-    var numberOfBytes = decoder.readUint32();
-    var version = decoder.readUint32();
-    val.deviceInfo = decoder.decodeStructPointer(device$.UsbDeviceInfo);
-    return val;
-  };
-
-  UsbDeviceManagerClient_OnDeviceRemoved_Params.encode = function(encoder, val) {
-    var packed;
-    encoder.writeUint32(UsbDeviceManagerClient_OnDeviceRemoved_Params.encodedSize);
-    encoder.writeUint32(0);
-    encoder.encodeStructPointer(device$.UsbDeviceInfo, val.deviceInfo);
-  };
-  var kUsbDeviceManager_GetDevices_Name = 0;
-  var kUsbDeviceManager_GetDevice_Name = 1;
-  var kUsbDeviceManager_SetClient_Name = 2;
-
-  function UsbDeviceManagerPtr(handleOrPtrInfo) {
-    this.ptr = new bindings.InterfacePtrController(UsbDeviceManager,
-                                                   handleOrPtrInfo);
-  }
-
-  function UsbDeviceManagerAssociatedPtr(associatedInterfacePtrInfo) {
-    this.ptr = new associatedBindings.AssociatedInterfacePtrController(
-        UsbDeviceManager, associatedInterfacePtrInfo);
-  }
-
-  UsbDeviceManagerAssociatedPtr.prototype =
-      Object.create(UsbDeviceManagerPtr.prototype);
-  UsbDeviceManagerAssociatedPtr.prototype.constructor =
-      UsbDeviceManagerAssociatedPtr;
-
-  function UsbDeviceManagerProxy(receiver) {
-    this.receiver_ = receiver;
-  }
-  UsbDeviceManagerPtr.prototype.getDevices = function() {
-    return UsbDeviceManagerProxy.prototype.getDevices
-        .apply(this.ptr.getProxy(), arguments);
-  };
-
-  UsbDeviceManagerProxy.prototype.getDevices = function(options) {
-    var params = new UsbDeviceManager_GetDevices_Params();
-    params.options = options;
-    return new Promise(function(resolve, reject) {
-      var builder = new codec.MessageV1Builder(
-          kUsbDeviceManager_GetDevices_Name,
-          codec.align(UsbDeviceManager_GetDevices_Params.encodedSize),
-          codec.kMessageExpectsResponse, 0);
-      builder.encodeStruct(UsbDeviceManager_GetDevices_Params, params);
-      var message = builder.finish();
-      this.receiver_.acceptAndExpectResponse(message).then(function(message) {
-        var reader = new codec.MessageReader(message);
-        var responseParams =
-            reader.decodeStruct(UsbDeviceManager_GetDevices_ResponseParams);
-        resolve(responseParams);
-      }).catch(function(result) {
-        reject(Error("Connection error: " + result));
-      });
-    }.bind(this));
-  };
-  UsbDeviceManagerPtr.prototype.getDevice = function() {
-    return UsbDeviceManagerProxy.prototype.getDevice
-        .apply(this.ptr.getProxy(), arguments);
-  };
-
-  UsbDeviceManagerProxy.prototype.getDevice = function(guid, deviceRequest) {
-    var params = new UsbDeviceManager_GetDevice_Params();
-    params.guid = guid;
-    params.deviceRequest = deviceRequest;
-    var builder = new codec.MessageV0Builder(
-        kUsbDeviceManager_GetDevice_Name,
-        codec.align(UsbDeviceManager_GetDevice_Params.encodedSize));
-    builder.encodeStruct(UsbDeviceManager_GetDevice_Params, params);
-    var message = builder.finish();
-    this.receiver_.accept(message);
-  };
-  UsbDeviceManagerPtr.prototype.setClient = function() {
-    return UsbDeviceManagerProxy.prototype.setClient
-        .apply(this.ptr.getProxy(), arguments);
-  };
-
-  UsbDeviceManagerProxy.prototype.setClient = function(client) {
-    var params = new UsbDeviceManager_SetClient_Params();
-    params.client = client;
-    var builder = new codec.MessageV0Builder(
-        kUsbDeviceManager_SetClient_Name,
-        codec.align(UsbDeviceManager_SetClient_Params.encodedSize));
-    builder.encodeStruct(UsbDeviceManager_SetClient_Params, params);
-    var message = builder.finish();
-    this.receiver_.accept(message);
-  };
-
-  function UsbDeviceManagerStub(delegate) {
-    this.delegate_ = delegate;
-  }
-  UsbDeviceManagerStub.prototype.getDevices = function(options) {
-    return this.delegate_ && this.delegate_.getDevices && this.delegate_.getDevices(options);
-  }
-  UsbDeviceManagerStub.prototype.getDevice = function(guid, deviceRequest) {
-    return this.delegate_ && this.delegate_.getDevice && this.delegate_.getDevice(guid, deviceRequest);
-  }
-  UsbDeviceManagerStub.prototype.setClient = function(client) {
-    return this.delegate_ && this.delegate_.setClient && this.delegate_.setClient(client);
-  }
-
-  UsbDeviceManagerStub.prototype.accept = function(message) {
-    var reader = new codec.MessageReader(message);
-    switch (reader.messageName) {
-    case kUsbDeviceManager_GetDevice_Name:
-      var params = reader.decodeStruct(UsbDeviceManager_GetDevice_Params);
-      this.getDevice(params.guid, params.deviceRequest);
-      return true;
-    case kUsbDeviceManager_SetClient_Name:
-      var params = reader.decodeStruct(UsbDeviceManager_SetClient_Params);
-      this.setClient(params.client);
-      return true;
-    default:
-      return false;
-    }
-  };
-
-  UsbDeviceManagerStub.prototype.acceptWithResponder =
-      function(message, responder) {
-    var reader = new codec.MessageReader(message);
-    switch (reader.messageName) {
-    case kUsbDeviceManager_GetDevices_Name:
-      var params = reader.decodeStruct(UsbDeviceManager_GetDevices_Params);
-      this.getDevices(params.options).then(function(response) {
-        var responseParams =
-            new UsbDeviceManager_GetDevices_ResponseParams();
-        responseParams.results = response.results;
-        var builder = new codec.MessageV1Builder(
-            kUsbDeviceManager_GetDevices_Name,
-            codec.align(UsbDeviceManager_GetDevices_ResponseParams.encodedSize),
-            codec.kMessageIsResponse, reader.requestID);
-        builder.encodeStruct(UsbDeviceManager_GetDevices_ResponseParams,
-                             responseParams);
-        var message = builder.finish();
-        responder.accept(message);
-      });
-      return true;
-    default:
-      return false;
-    }
-  };
-
-  function validateUsbDeviceManagerRequest(messageValidator) {
-    var message = messageValidator.message;
-    var paramsClass = null;
-    switch (message.getName()) {
-      case kUsbDeviceManager_GetDevices_Name:
-        if (message.expectsResponse())
-          paramsClass = UsbDeviceManager_GetDevices_Params;
-      break;
-      case kUsbDeviceManager_GetDevice_Name:
-        if (!message.expectsResponse() && !message.isResponse())
-          paramsClass = UsbDeviceManager_GetDevice_Params;
-      break;
-      case kUsbDeviceManager_SetClient_Name:
-        if (!message.expectsResponse() && !message.isResponse())
-          paramsClass = UsbDeviceManager_SetClient_Params;
-      break;
-    }
-    if (paramsClass === null)
-      return validator.validationError.NONE;
-    return paramsClass.validate(messageValidator, messageValidator.message.getHeaderNumBytes());
-  }
-
-  function validateUsbDeviceManagerResponse(messageValidator) {
-   var message = messageValidator.message;
-   var paramsClass = null;
-   switch (message.getName()) {
-      case kUsbDeviceManager_GetDevices_Name:
-        if (message.isResponse())
-          paramsClass = UsbDeviceManager_GetDevices_ResponseParams;
-        break;
-    }
-    if (paramsClass === null)
-      return validator.validationError.NONE;
-    return paramsClass.validate(messageValidator, messageValidator.message.getHeaderNumBytes());
-  }
-
-  var UsbDeviceManager = {
-    name: 'device.mojom.UsbDeviceManager',
-    kVersion: 0,
-    ptrClass: UsbDeviceManagerPtr,
-    proxyClass: UsbDeviceManagerProxy,
-    stubClass: UsbDeviceManagerStub,
-    validateRequest: validateUsbDeviceManagerRequest,
-    validateResponse: validateUsbDeviceManagerResponse,
-  };
-  UsbDeviceManagerStub.prototype.validator = validateUsbDeviceManagerRequest;
-  UsbDeviceManagerProxy.prototype.validator = validateUsbDeviceManagerResponse;
-  var kUsbDeviceManagerClient_OnDeviceAdded_Name = 0;
-  var kUsbDeviceManagerClient_OnDeviceRemoved_Name = 1;
-
-  function UsbDeviceManagerClientPtr(handleOrPtrInfo) {
-    this.ptr = new bindings.InterfacePtrController(UsbDeviceManagerClient,
-                                                   handleOrPtrInfo);
-  }
-
-  function UsbDeviceManagerClientAssociatedPtr(associatedInterfacePtrInfo) {
-    this.ptr = new associatedBindings.AssociatedInterfacePtrController(
-        UsbDeviceManagerClient, associatedInterfacePtrInfo);
-  }
-
-  UsbDeviceManagerClientAssociatedPtr.prototype =
-      Object.create(UsbDeviceManagerClientPtr.prototype);
-  UsbDeviceManagerClientAssociatedPtr.prototype.constructor =
-      UsbDeviceManagerClientAssociatedPtr;
-
-  function UsbDeviceManagerClientProxy(receiver) {
-    this.receiver_ = receiver;
-  }
-  UsbDeviceManagerClientPtr.prototype.onDeviceAdded = function() {
-    return UsbDeviceManagerClientProxy.prototype.onDeviceAdded
-        .apply(this.ptr.getProxy(), arguments);
-  };
-
-  UsbDeviceManagerClientProxy.prototype.onDeviceAdded = function(deviceInfo) {
-    var params = new UsbDeviceManagerClient_OnDeviceAdded_Params();
-    params.deviceInfo = deviceInfo;
-    var builder = new codec.MessageV0Builder(
-        kUsbDeviceManagerClient_OnDeviceAdded_Name,
-        codec.align(UsbDeviceManagerClient_OnDeviceAdded_Params.encodedSize));
-    builder.encodeStruct(UsbDeviceManagerClient_OnDeviceAdded_Params, params);
-    var message = builder.finish();
-    this.receiver_.accept(message);
-  };
-  UsbDeviceManagerClientPtr.prototype.onDeviceRemoved = function() {
-    return UsbDeviceManagerClientProxy.prototype.onDeviceRemoved
-        .apply(this.ptr.getProxy(), arguments);
-  };
-
-  UsbDeviceManagerClientProxy.prototype.onDeviceRemoved = function(deviceInfo) {
-    var params = new UsbDeviceManagerClient_OnDeviceRemoved_Params();
-    params.deviceInfo = deviceInfo;
-    var builder = new codec.MessageV0Builder(
-        kUsbDeviceManagerClient_OnDeviceRemoved_Name,
-        codec.align(UsbDeviceManagerClient_OnDeviceRemoved_Params.encodedSize));
-    builder.encodeStruct(UsbDeviceManagerClient_OnDeviceRemoved_Params, params);
-    var message = builder.finish();
-    this.receiver_.accept(message);
-  };
-
-  function UsbDeviceManagerClientStub(delegate) {
-    this.delegate_ = delegate;
-  }
-  UsbDeviceManagerClientStub.prototype.onDeviceAdded = function(deviceInfo) {
-    return this.delegate_ && this.delegate_.onDeviceAdded && this.delegate_.onDeviceAdded(deviceInfo);
-  }
-  UsbDeviceManagerClientStub.prototype.onDeviceRemoved = function(deviceInfo) {
-    return this.delegate_ && this.delegate_.onDeviceRemoved && this.delegate_.onDeviceRemoved(deviceInfo);
-  }
-
-  UsbDeviceManagerClientStub.prototype.accept = function(message) {
-    var reader = new codec.MessageReader(message);
-    switch (reader.messageName) {
-    case kUsbDeviceManagerClient_OnDeviceAdded_Name:
-      var params = reader.decodeStruct(UsbDeviceManagerClient_OnDeviceAdded_Params);
-      this.onDeviceAdded(params.deviceInfo);
-      return true;
-    case kUsbDeviceManagerClient_OnDeviceRemoved_Name:
-      var params = reader.decodeStruct(UsbDeviceManagerClient_OnDeviceRemoved_Params);
-      this.onDeviceRemoved(params.deviceInfo);
-      return true;
-    default:
-      return false;
-    }
-  };
-
-  UsbDeviceManagerClientStub.prototype.acceptWithResponder =
-      function(message, responder) {
-    var reader = new codec.MessageReader(message);
-    switch (reader.messageName) {
-    default:
-      return false;
-    }
-  };
-
-  function validateUsbDeviceManagerClientRequest(messageValidator) {
-    var message = messageValidator.message;
-    var paramsClass = null;
-    switch (message.getName()) {
-      case kUsbDeviceManagerClient_OnDeviceAdded_Name:
-        if (!message.expectsResponse() && !message.isResponse())
-          paramsClass = UsbDeviceManagerClient_OnDeviceAdded_Params;
-      break;
-      case kUsbDeviceManagerClient_OnDeviceRemoved_Name:
-        if (!message.expectsResponse() && !message.isResponse())
-          paramsClass = UsbDeviceManagerClient_OnDeviceRemoved_Params;
-      break;
-    }
-    if (paramsClass === null)
-      return validator.validationError.NONE;
-    return paramsClass.validate(messageValidator, messageValidator.message.getHeaderNumBytes());
-  }
-
-  function validateUsbDeviceManagerClientResponse(messageValidator) {
-    return validator.validationError.NONE;
-  }
-
-  var UsbDeviceManagerClient = {
-    name: 'device.mojom.UsbDeviceManagerClient',
-    kVersion: 0,
-    ptrClass: UsbDeviceManagerClientPtr,
-    proxyClass: UsbDeviceManagerClientProxy,
-    stubClass: UsbDeviceManagerClientStub,
-    validateRequest: validateUsbDeviceManagerClientRequest,
-    validateResponse: null,
-  };
-  UsbDeviceManagerClientStub.prototype.validator = validateUsbDeviceManagerClientRequest;
-  UsbDeviceManagerClientProxy.prototype.validator = null;
-  exports.UsbDeviceFilter = UsbDeviceFilter;
-  exports.UsbEnumerationOptions = UsbEnumerationOptions;
-  exports.UsbDeviceManager = UsbDeviceManager;
-  exports.UsbDeviceManagerPtr = UsbDeviceManagerPtr;
-  exports.UsbDeviceManagerAssociatedPtr = UsbDeviceManagerAssociatedPtr;
-  exports.UsbDeviceManagerClient = UsbDeviceManagerClient;
-  exports.UsbDeviceManagerClientPtr = UsbDeviceManagerClientPtr;
-  exports.UsbDeviceManagerClientAssociatedPtr = UsbDeviceManagerClientAssociatedPtr;
-})();
deleted file mode 100644
--- a/testing/web-platform/tests/resources/chromium/device_manager.mojom.js.headers
+++ /dev/null
@@ -1,1 +0,0 @@
-Content-Type: text/javascript; charset=utf-8
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/resources/chromium/device_manager_client.mojom.js
@@ -0,0 +1,262 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+'use strict';
+
+(function() {
+  var mojomId = 'device/usb/public/mojom/device_manager_client.mojom';
+  if (mojo.internal.isMojomLoaded(mojomId)) {
+    console.warn('The following mojom is loaded multiple times: ' + mojomId);
+    return;
+  }
+  mojo.internal.markMojomLoaded(mojomId);
+  var bindings = mojo;
+  var associatedBindings = mojo;
+  var codec = mojo.internal;
+  var validator = mojo.internal;
+
+  var exports = mojo.internal.exposeNamespace('device.mojom');
+  var device$ =
+      mojo.internal.exposeNamespace('device.mojom');
+  if (mojo.config.autoLoadMojomDeps) {
+    mojo.internal.loadMojomIfNecessary(
+        'device/usb/public/mojom/device.mojom', 'device.mojom.js');
+  }
+
+
+
+  function UsbDeviceManagerClient_OnDeviceAdded_Params(values) {
+    this.initDefaults_();
+    this.initFields_(values);
+  }
+
+
+  UsbDeviceManagerClient_OnDeviceAdded_Params.prototype.initDefaults_ = function() {
+    this.deviceInfo = null;
+  };
+  UsbDeviceManagerClient_OnDeviceAdded_Params.prototype.initFields_ = function(fields) {
+    for(var field in fields) {
+        if (this.hasOwnProperty(field))
+          this[field] = fields[field];
+    }
+  };
+
+  UsbDeviceManagerClient_OnDeviceAdded_Params.validate = function(messageValidator, offset) {
+    var err;
+    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
+    if (err !== validator.validationError.NONE)
+        return err;
+
+    var kVersionSizes = [
+      {version: 0, numBytes: 16}
+    ];
+    err = messageValidator.validateStructVersion(offset, kVersionSizes);
+    if (err !== validator.validationError.NONE)
+        return err;
+
+
+    // validate UsbDeviceManagerClient_OnDeviceAdded_Params.deviceInfo
+    err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 0, device$.UsbDeviceInfo, false);
+    if (err !== validator.validationError.NONE)
+        return err;
+
+    return validator.validationError.NONE;
+  };
+
+  UsbDeviceManagerClient_OnDeviceAdded_Params.encodedSize = codec.kStructHeaderSize + 8;
+
+  UsbDeviceManagerClient_OnDeviceAdded_Params.decode = function(decoder) {
+    var packed;
+    var val = new UsbDeviceManagerClient_OnDeviceAdded_Params();
+    var numberOfBytes = decoder.readUint32();
+    var version = decoder.readUint32();
+    val.deviceInfo = decoder.decodeStructPointer(device$.UsbDeviceInfo);
+    return val;
+  };
+
+  UsbDeviceManagerClient_OnDeviceAdded_Params.encode = function(encoder, val) {
+    var packed;
+    encoder.writeUint32(UsbDeviceManagerClient_OnDeviceAdded_Params.encodedSize);
+    encoder.writeUint32(0);
+    encoder.encodeStructPointer(device$.UsbDeviceInfo, val.deviceInfo);
+  };
+  function UsbDeviceManagerClient_OnDeviceRemoved_Params(values) {
+    this.initDefaults_();
+    this.initFields_(values);
+  }
+
+
+  UsbDeviceManagerClient_OnDeviceRemoved_Params.prototype.initDefaults_ = function() {
+    this.deviceInfo = null;
+  };
+  UsbDeviceManagerClient_OnDeviceRemoved_Params.prototype.initFields_ = function(fields) {
+    for(var field in fields) {
+        if (this.hasOwnProperty(field))
+          this[field] = fields[field];
+    }
+  };
+
+  UsbDeviceManagerClient_OnDeviceRemoved_Params.validate = function(messageValidator, offset) {
+    var err;
+    err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
+    if (err !== validator.validationError.NONE)
+        return err;
+
+    var kVersionSizes = [
+      {version: 0, numBytes: 16}
+    ];
+    err = messageValidator.validateStructVersion(offset, kVersionSizes);
+    if (err !== validator.validationError.NONE)
+        return err;
+
+
+    // validate UsbDeviceManagerClient_OnDeviceRemoved_Params.deviceInfo
+    err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 0, device$.UsbDeviceInfo, false);
+    if (err !== validator.validationError.NONE)
+        return err;
+
+    return validator.validationError.NONE;
+  };
+
+  UsbDeviceManagerClient_OnDeviceRemoved_Params.encodedSize = codec.kStructHeaderSize + 8;
+
+  UsbDeviceManagerClient_OnDeviceRemoved_Params.decode = function(decoder) {
+    var packed;
+    var val = new UsbDeviceManagerClient_OnDeviceRemoved_Params();
+    var numberOfBytes = decoder.readUint32();
+    var version = decoder.readUint32();
+    val.deviceInfo = decoder.decodeStructPointer(device$.UsbDeviceInfo);
+    return val;
+  };
+
+  UsbDeviceManagerClient_OnDeviceRemoved_Params.encode = function(encoder, val) {
+    var packed;
+    encoder.writeUint32(UsbDeviceManagerClient_OnDeviceRemoved_Params.encodedSize);
+    encoder.writeUint32(0);
+    encoder.encodeStructPointer(device$.UsbDeviceInfo, val.deviceInfo);
+  };
+  var kUsbDeviceManagerClient_OnDeviceAdded_Name = 0;
+  var kUsbDeviceManagerClient_OnDeviceRemoved_Name = 1;
+
+  function UsbDeviceManagerClientPtr(handleOrPtrInfo) {
+    this.ptr = new bindings.InterfacePtrController(UsbDeviceManagerClient,
+                                                   handleOrPtrInfo);
+  }
+
+  function UsbDeviceManagerClientAssociatedPtr(associatedInterfacePtrInfo) {
+    this.ptr = new associatedBindings.AssociatedInterfacePtrController(
+        UsbDeviceManagerClient, associatedInterfacePtrInfo);
+  }
+
+  UsbDeviceManagerClientAssociatedPtr.prototype =
+      Object.create(UsbDeviceManagerClientPtr.prototype);
+  UsbDeviceManagerClientAssociatedPtr.prototype.constructor =
+      UsbDeviceManagerClientAssociatedPtr;
+
+  function UsbDeviceManagerClientProxy(receiver) {
+    this.receiver_ = receiver;
+  }
+  UsbDeviceManagerClientPtr.prototype.onDeviceAdded = function() {
+    return UsbDeviceManagerClientProxy.prototype.onDeviceAdded
+        .apply(this.ptr.getProxy(), arguments);
+  };
+
+  UsbDeviceManagerClientProxy.prototype.onDeviceAdded = function(deviceInfo) {
+    var params_ = new UsbDeviceManagerClient_OnDeviceAdded_Params();
+    params_.deviceInfo = deviceInfo;
+    var builder = new codec.MessageV0Builder(
+        kUsbDeviceManagerClient_OnDeviceAdded_Name,
+        codec.align(UsbDeviceManagerClient_OnDeviceAdded_Params.encodedSize));
+    builder.encodeStruct(UsbDeviceManagerClient_OnDeviceAdded_Params, params_);
+    var message = builder.finish();
+    this.receiver_.accept(message);
+  };
+  UsbDeviceManagerClientPtr.prototype.onDeviceRemoved = function() {
+    return UsbDeviceManagerClientProxy.prototype.onDeviceRemoved
+        .apply(this.ptr.getProxy(), arguments);
+  };
+
+  UsbDeviceManagerClientProxy.prototype.onDeviceRemoved = function(deviceInfo) {
+    var params_ = new UsbDeviceManagerClient_OnDeviceRemoved_Params();
+    params_.deviceInfo = deviceInfo;
+    var builder = new codec.MessageV0Builder(
+        kUsbDeviceManagerClient_OnDeviceRemoved_Name,
+        codec.align(UsbDeviceManagerClient_OnDeviceRemoved_Params.encodedSize));
+    builder.encodeStruct(UsbDeviceManagerClient_OnDeviceRemoved_Params, params_);
+    var message = builder.finish();
+    this.receiver_.accept(message);
+  };
+
+  function UsbDeviceManagerClientStub(delegate) {
+    this.delegate_ = delegate;
+  }
+  UsbDeviceManagerClientStub.prototype.onDeviceAdded = function(deviceInfo) {
+    return this.delegate_ && this.delegate_.onDeviceAdded && this.delegate_.onDeviceAdded(deviceInfo);
+  }
+  UsbDeviceManagerClientStub.prototype.onDeviceRemoved = function(deviceInfo) {
+    return this.delegate_ && this.delegate_.onDeviceRemoved && this.delegate_.onDeviceRemoved(deviceInfo);
+  }
+
+  UsbDeviceManagerClientStub.prototype.accept = function(message) {
+    var reader = new codec.MessageReader(message);
+    switch (reader.messageName) {
+    case kUsbDeviceManagerClient_OnDeviceAdded_Name:
+      var params = reader.decodeStruct(UsbDeviceManagerClient_OnDeviceAdded_Params);
+      this.onDeviceAdded(params.deviceInfo);
+      return true;
+    case kUsbDeviceManagerClient_OnDeviceRemoved_Name:
+      var params = reader.decodeStruct(UsbDeviceManagerClient_OnDeviceRemoved_Params);
+      this.onDeviceRemoved(params.deviceInfo);
+      return true;
+    default:
+      return false;
+    }
+  };
+
+  UsbDeviceManagerClientStub.prototype.acceptWithResponder =
+      function(message, responder) {
+    var reader = new codec.MessageReader(message);
+    switch (reader.messageName) {
+    default:
+      return false;
+    }
+  };
+
+  function validateUsbDeviceManagerClientRequest(messageValidator) {
+    var message = messageValidator.message;
+    var paramsClass = null;
+    switch (message.getName()) {
+      case kUsbDeviceManagerClient_OnDeviceAdded_Name:
+        if (!message.expectsResponse() && !message.isResponse())
+          paramsClass = UsbDeviceManagerClient_OnDeviceAdded_Params;
+      break;
+      case kUsbDeviceManagerClient_OnDeviceRemoved_Name:
+        if (!message.expectsResponse() && !message.isResponse())
+          paramsClass = UsbDeviceManagerClient_OnDeviceRemoved_Params;
+      break;
+    }
+    if (paramsClass === null)
+      return validator.validationError.NONE;
+    return paramsClass.validate(messageValidator, messageValidator.message.getHeaderNumBytes());
+  }
+
+  function validateUsbDeviceManagerClientResponse(messageValidator) {
+    return validator.validationError.NONE;
+  }
+
+  var UsbDeviceManagerClient = {
+    name: 'device.mojom.UsbDeviceManagerClient',
+    kVersion: 0,
+    ptrClass: UsbDeviceManagerClientPtr,
+    proxyClass: UsbDeviceManagerClientProxy,
+    stubClass: UsbDeviceManagerClientStub,
+    validateRequest: validateUsbDeviceManagerClientRequest,
+    validateResponse: null,
+  };
+  UsbDeviceManagerClientStub.prototype.validator = validateUsbDeviceManagerClientRequest;
+  UsbDeviceManagerClientProxy.prototype.validator = null;
+  exports.UsbDeviceManagerClient = UsbDeviceManagerClient;
+  exports.UsbDeviceManagerClientPtr = UsbDeviceManagerClientPtr;
+  exports.UsbDeviceManagerClientAssociatedPtr = UsbDeviceManagerClientAssociatedPtr;
+})();
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/resources/chromium/device_manager_client.mojom.js.headers
@@ -0,0 +1,1 @@
+Content-Type: text/javascript; charset=utf-8
\ No newline at end of file
--- a/testing/web-platform/tests/resources/chromium/mojo_bindings.js
+++ b/testing/web-platform/tests/resources/chromium/mojo_bindings.js
@@ -1,22 +1,29 @@
 // Copyright 2017 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 'use strict';
 
-if (mojo && mojo.internal) {
+if ((typeof mojo !== 'undefined') && mojo.bindingsLibraryInitialized) {
   throw new Error('The Mojo bindings library has been initialized.');
 }
 
 var mojo = mojo || {};
-mojo.internal = {};
-mojo.internal.global = this;
-mojo.config = {
+mojo.bindingsLibraryInitialized = true;
+
+mojo.internal = mojo.internal || {};
+
+mojo.config = mojo.config || {};
+if (typeof mojo.config.global === 'undefined') {
+  mojo.config.global = this;
+}
+
+if (typeof mojo.config.autoLoadMojomDeps === 'undefined') {
   // Whether to automatically load mojom dependencies.
   // For example, if foo.mojom imports bar.mojom, |autoLoadMojomDeps| set to
   // true means that loading foo.mojom.js will insert a <script> tag to load
   // bar.mojom.js, if it hasn't been loaded.
   //
   // The URL of bar.mojom.js is determined by the relative path of bar.mojom
   // (relative to the position of foo.mojom at build time) and the URL of
   // foo.mojom.js. For exmple, if at build time the two mojom files are
@@ -47,31 +54,32 @@ mojo.config = {
   // <script src="http://example.org/scripts/b/d/bar.mojom.js"></script>
   // <script src="http://example.org/scripts/b/c/foo.mojom.js"></script>
   //
   // Load bar.mojom.js twice; should be avoided:
   // <script src="http://example.org/scripts/b/c/foo.mojom.js"></script>
   // <script src="http://example.org/scripts/b/d/bar.mojom.js"></script>
   //
   // -->
-  autoLoadMojomDeps: true
-};
+  mojo.config.autoLoadMojomDeps = true;
+}
 
 (function() {
   var internal = mojo.internal;
+  var config = mojo.config;
 
   var LoadState = {
     PENDING_LOAD: 1,
     LOADED: 2
   };
 
   var mojomRegistry = new Map();
 
   function exposeNamespace(namespace) {
-    var current = internal.global;
+    var current = config.global;
     var parts = namespace.split('.');
 
     for (var part; parts.length && (part = parts.shift());) {
       if (!current[part]) {
         current[part] = {};
       }
       current = current[part];
     }
@@ -99,27 +107,27 @@ mojo.config = {
     mojomRegistry.set(id, LoadState.LOADED);
   }
 
   function loadMojomIfNecessary(id, relativePath) {
     if (mojomRegistry.has(id)) {
       return;
     }
 
-    if (internal.global.document === undefined) {
+    if (config.global.document === undefined) {
       throw new Error(
           'Mojom dependency autoloading is not implemented in workers. ' +
           'Please see config variable mojo.config.autoLoadMojomDeps for more ' +
           'details.');
     }
 
     markMojomPendingLoad(id);
     var url = new URL(relativePath, document.currentScript.src).href;
-    internal.global.document.write('<script type="text/javascript" src="' +
-                                   url + '"><' + '/script>');
+    config.global.document.write('<script type="text/javascript" src="' +
+                                 url + '"><' + '/script>');
   }
 
   internal.exposeNamespace = exposeNamespace;
   internal.isMojomPendingLoad = isMojomPendingLoad;
   internal.isMojomLoaded = isMojomLoaded;
   internal.markMojomPendingLoad = markMojomPendingLoad;
   internal.markMojomLoaded = markMojomLoaded;
   internal.loadMojomIfNecessary = loadMojomIfNecessary;
@@ -667,16 +675,113 @@ mojo.config = {
   mojo.makeRequest = makeRequest;
   mojo.AssociatedInterfacePtrController = AssociatedInterfacePtrController;
   mojo.AssociatedBinding = AssociatedBinding;
   mojo.AssociatedBindingSet = AssociatedBindingSet;
   mojo.Binding = Binding;
   mojo.BindingSet = BindingSet;
   mojo.InterfacePtrController = InterfacePtrController;
 })();
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+(function() {
+  var internal = mojo.internal;
+
+  // Constants ----------------------------------------------------------------
+  var kInterfaceIdNamespaceMask = 0x80000000;
+  var kMasterInterfaceId = 0x00000000;
+  var kInvalidInterfaceId = 0xFFFFFFFF;
+
+  // ---------------------------------------------------------------------------
+
+  function InterfacePtrInfo(handle, version) {
+    this.handle = handle;
+    this.version = version;
+  }
+
+  InterfacePtrInfo.prototype.isValid = function() {
+    return this.handle instanceof MojoHandle;
+  };
+
+  InterfacePtrInfo.prototype.close = function() {
+    if (!this.isValid())
+      return;
+
+    this.handle.close();
+    this.handle = null;
+    this.version = 0;
+  };
+
+  function AssociatedInterfacePtrInfo(interfaceEndpointHandle, version) {
+    this.interfaceEndpointHandle = interfaceEndpointHandle;
+    this.version = version;
+  }
+
+  AssociatedInterfacePtrInfo.prototype.isValid = function() {
+    return this.interfaceEndpointHandle.isValid();
+  };
+
+  // ---------------------------------------------------------------------------
+
+  function InterfaceRequest(handle) {
+    this.handle = handle;
+  }
+
+  InterfaceRequest.prototype.isValid = function() {
+    return this.handle instanceof MojoHandle;
+  };
+
+  InterfaceRequest.prototype.close = function() {
+    if (!this.isValid())
+      return;
+
+    this.handle.close();
+    this.handle = null;
+  };
+
+  function AssociatedInterfaceRequest(interfaceEndpointHandle) {
+    this.interfaceEndpointHandle = interfaceEndpointHandle;
+  }
+
+  AssociatedInterfaceRequest.prototype.isValid = function() {
+    return this.interfaceEndpointHandle.isValid();
+  };
+
+  AssociatedInterfaceRequest.prototype.resetWithReason = function(reason) {
+    this.interfaceEndpointHandle.reset(reason);
+  };
+
+  function isMasterInterfaceId(interfaceId) {
+    return interfaceId === kMasterInterfaceId;
+  }
+
+  function isValidInterfaceId(interfaceId) {
+    return interfaceId !== kInvalidInterfaceId;
+  }
+
+  function hasInterfaceIdNamespaceBitSet(interfaceId) {
+    if (interfaceId >= 2 * kInterfaceIdNamespaceMask) {
+      throw new Error("Interface ID should be a 32-bit unsigned integer.");
+    }
+    return interfaceId >= kInterfaceIdNamespaceMask;
+  }
+
+  mojo.InterfacePtrInfo = InterfacePtrInfo;
+  mojo.InterfaceRequest = InterfaceRequest;
+  mojo.AssociatedInterfacePtrInfo = AssociatedInterfacePtrInfo;
+  mojo.AssociatedInterfaceRequest = AssociatedInterfaceRequest;
+  internal.isMasterInterfaceId = isMasterInterfaceId;
+  internal.isValidInterfaceId = isValidInterfaceId;
+  internal.hasInterfaceIdNamespaceBitSet = hasInterfaceIdNamespaceBitSet;
+  internal.kInvalidInterfaceId = kInvalidInterfaceId;
+  internal.kMasterInterfaceId = kMasterInterfaceId;
+  internal.kInterfaceIdNamespaceMask = kInterfaceIdNamespaceMask;
+})();
 // Copyright 2014 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 (function() {
   var internal = mojo.internal;
 
   var kHostIsLittleEndian = (function () {
@@ -2066,16 +2171,20 @@ mojo.config = {
             false);
         return;
       }
       var messageBuffer = new internal.Buffer(read.buffer);
       var message = new internal.Message(messageBuffer, read.handles);
       var receiverResult = this.incomingReceiver_ &&
           this.incomingReceiver_.accept(message);
 
+      // Dispatching the message may have closed the connector.
+      if (this.handle_ == null)
+        return;
+
       // Handle invalid incoming message.
       if (!internal.isTestingMode() && !receiverResult) {
         // TODO(yzshen): Consider notifying the embedder.
         this.handleError(true, false);
       }
     }
   };
 
@@ -2126,190 +2235,101 @@ mojo.config = {
       if (this.errorHandler_) {
         this.errorHandler_.onError();
       }
     }
   };
 
   internal.Connector = Connector;
 })();
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-(function() {
-  var internal = mojo.internal;
-
-  // Constants ----------------------------------------------------------------
-  var kInterfaceIdNamespaceMask = 0x80000000;
-  var kMasterInterfaceId = 0x00000000;
-  var kInvalidInterfaceId = 0xFFFFFFFF;
-
-  // ---------------------------------------------------------------------------
-
-  function InterfacePtrInfo(handle, version) {
-    this.handle = handle;
-    this.version = version;
-  }
-
-  InterfacePtrInfo.prototype.isValid = function() {
-    return this.handle instanceof MojoHandle;
-  };
-
-  InterfacePtrInfo.prototype.close = function() {
-    if (!this.isValid())
-      return;
-
-    this.handle.close();
-    this.handle = null;
-    this.version = 0;
-  };
-
-  function AssociatedInterfacePtrInfo(interfaceEndpointHandle, version) {
-    this.interfaceEndpointHandle = interfaceEndpointHandle;
-    this.version = version;
-  }
-
-  AssociatedInterfacePtrInfo.prototype.isValid = function() {
-    return this.interfaceEndpointHandle.isValid();
-  };
-
-  // ---------------------------------------------------------------------------
-
-  function InterfaceRequest(handle) {
-    this.handle = handle;
-  }
-
-  InterfaceRequest.prototype.isValid = function() {
-    return this.handle instanceof MojoHandle;
-  };
-
-  InterfaceRequest.prototype.close = function() {
-    if (!this.isValid())
-      return;
-
-    this.handle.close();
-    this.handle = null;
-  };
-
-  function AssociatedInterfaceRequest(interfaceEndpointHandle) {
-    this.interfaceEndpointHandle = interfaceEndpointHandle;
-  }
-
-  AssociatedInterfaceRequest.prototype.isValid = function() {
-    return this.interfaceEndpointHandle.isValid();
-  };
-
-  AssociatedInterfaceRequest.prototype.resetWithReason = function(reason) {
-    this.interfaceEndpointHandle.reset(reason);
-  };
-
-  function isMasterInterfaceId(interfaceId) {
-    return interfaceId === kMasterInterfaceId;
-  }
-
-  function isValidInterfaceId(interfaceId) {
-    return interfaceId !== kInvalidInterfaceId;
-  }
-
-  mojo.InterfacePtrInfo = InterfacePtrInfo;
-  mojo.InterfaceRequest = InterfaceRequest;
-  mojo.AssociatedInterfacePtrInfo = AssociatedInterfacePtrInfo;
-  mojo.AssociatedInterfaceRequest = AssociatedInterfaceRequest;
-  internal.isMasterInterfaceId = isMasterInterfaceId;
-  internal.isValidInterfaceId = isValidInterfaceId;
-  internal.kInvalidInterfaceId = kInvalidInterfaceId;
-  internal.kMasterInterfaceId = kMasterInterfaceId;
-  internal.kInterfaceIdNamespaceMask = kInterfaceIdNamespaceMask;
-})();
 // Copyright 2017 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 (function() {
   var internal = mojo.internal;
 
   function validateControlRequestWithResponse(message) {
     var messageValidator = new internal.Validator(message);
     var error = messageValidator.validateMessageIsRequestExpectingResponse();
     if (error !== internal.validationError.NONE) {
       throw error;
     }
 
-    if (message.getName() != mojo.interfaceControl2.kRunMessageId) {
+    if (message.getName() != mojo.interfaceControl.kRunMessageId) {
       throw new Error("Control message name is not kRunMessageId");
     }
 
     // Validate payload.
-    error = mojo.interfaceControl2.RunMessageParams.validate(messageValidator,
+    error = mojo.interfaceControl.RunMessageParams.validate(messageValidator,
         message.getHeaderNumBytes());
     if (error != internal.validationError.NONE) {
       throw error;
     }
   }
 
   function validateControlRequestWithoutResponse(message) {
     var messageValidator = new internal.Validator(message);
     var error = messageValidator.validateMessageIsRequestWithoutResponse();
     if (error != internal.validationError.NONE) {
       throw error;
     }
 
-    if (message.getName() != mojo.interfaceControl2.kRunOrClosePipeMessageId) {
+    if (message.getName() != mojo.interfaceControl.kRunOrClosePipeMessageId) {
       throw new Error("Control message name is not kRunOrClosePipeMessageId");
     }
 
     // Validate payload.
-    error = mojo.interfaceControl2.RunOrClosePipeMessageParams.validate(
+    error = mojo.interfaceControl.RunOrClosePipeMessageParams.validate(
         messageValidator, message.getHeaderNumBytes());
     if (error != internal.validationError.NONE) {
       throw error;
     }
   }
 
   function runOrClosePipe(message, interfaceVersion) {
     var reader = new internal.MessageReader(message);
     var runOrClosePipeMessageParams = reader.decodeStruct(
-        mojo.interfaceControl2.RunOrClosePipeMessageParams);
+        mojo.interfaceControl.RunOrClosePipeMessageParams);
     return interfaceVersion >=
         runOrClosePipeMessageParams.input.requireVersion.version;
   }
 
   function run(message, responder, interfaceVersion) {
     var reader = new internal.MessageReader(message);
     var runMessageParams =
-        reader.decodeStruct(mojo.interfaceControl2.RunMessageParams);
+        reader.decodeStruct(mojo.interfaceControl.RunMessageParams);
     var runOutput = null;
 
     if (runMessageParams.input.queryVersion) {
-      runOutput = new mojo.interfaceControl2.RunOutput();
+      runOutput = new mojo.interfaceControl.RunOutput();
       runOutput.queryVersionResult = new
-          mojo.interfaceControl2.QueryVersionResult(
+          mojo.interfaceControl.QueryVersionResult(
               {'version': interfaceVersion});
     }
 
     var runResponseMessageParams = new
-        mojo.interfaceControl2.RunResponseMessageParams();
+        mojo.interfaceControl.RunResponseMessageParams();
     runResponseMessageParams.output = runOutput;
 
-    var messageName = mojo.interfaceControl2.kRunMessageId;
+    var messageName = mojo.interfaceControl.kRunMessageId;
     var payloadSize =
-        mojo.interfaceControl2.RunResponseMessageParams.encodedSize;
+        mojo.interfaceControl.RunResponseMessageParams.encodedSize;
     var requestID = reader.requestID;
     var builder = new internal.MessageV1Builder(messageName,
         payloadSize, internal.kMessageIsResponse, requestID);
-    builder.encodeStruct(mojo.interfaceControl2.RunResponseMessageParams,
+    builder.encodeStruct(mojo.interfaceControl.RunResponseMessageParams,
                          runResponseMessageParams);
     responder.accept(builder.finish());
     return true;
   }
 
   function isInterfaceControlMessage(message) {
-    return message.getName() == mojo.interfaceControl2.kRunMessageId ||
-           message.getName() == mojo.interfaceControl2.kRunOrClosePipeMessageId;
+    return message.getName() == mojo.interfaceControl.kRunMessageId ||
+           message.getName() == mojo.interfaceControl.kRunOrClosePipeMessageId;
   }
 
   function ControlMessageHandler(interfaceVersion) {
     this.interfaceVersion_ = interfaceVersion;
   }
 
   ControlMessageHandler.prototype.accept = function(message) {
     validateControlRequestWithoutResponse(message);
@@ -2329,100 +2349,100 @@ mojo.config = {
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 (function() {
   var internal = mojo.internal;
 
   function constructRunOrClosePipeMessage(runOrClosePipeInput) {
     var runOrClosePipeMessageParams = new
-        mojo.interfaceControl2.RunOrClosePipeMessageParams();
+        mojo.interfaceControl.RunOrClosePipeMessageParams();
     runOrClosePipeMessageParams.input = runOrClosePipeInput;
 
-    var messageName = mojo.interfaceControl2.kRunOrClosePipeMessageId;
+    var messageName = mojo.interfaceControl.kRunOrClosePipeMessageId;
     var payloadSize =
-        mojo.interfaceControl2.RunOrClosePipeMessageParams.encodedSize;
+        mojo.interfaceControl.RunOrClosePipeMessageParams.encodedSize;
     var builder = new internal.MessageV0Builder(messageName, payloadSize);
-    builder.encodeStruct(mojo.interfaceControl2.RunOrClosePipeMessageParams,
+    builder.encodeStruct(mojo.interfaceControl.RunOrClosePipeMessageParams,
                          runOrClosePipeMessageParams);
     var message = builder.finish();
     return message;
   }
 
   function validateControlResponse(message) {
     var messageValidator = new internal.Validator(message);
     var error = messageValidator.validateMessageIsResponse();
     if (error != internal.validationError.NONE) {
       throw error;
     }
 
-    if (message.getName() != mojo.interfaceControl2.kRunMessageId) {
+    if (message.getName() != mojo.interfaceControl.kRunMessageId) {
       throw new Error("Control message name is not kRunMessageId");
     }
 
     // Validate payload.
-    error = mojo.interfaceControl2.RunResponseMessageParams.validate(
+    error = mojo.interfaceControl.RunResponseMessageParams.validate(
         messageValidator, message.getHeaderNumBytes());
     if (error != internal.validationError.NONE) {
       throw error;
     }
   }
 
   function acceptRunResponse(message) {
     validateControlResponse(message);
 
     var reader = new internal.MessageReader(message);
     var runResponseMessageParams = reader.decodeStruct(
-        mojo.interfaceControl2.RunResponseMessageParams);
+        mojo.interfaceControl.RunResponseMessageParams);
 
     return Promise.resolve(runResponseMessageParams);
   }
 
  /**
   * Sends the given run message through the receiver.
   * Accepts the response message from the receiver and decodes the message
   * struct to RunResponseMessageParams.
   *
   * @param  {Router} receiver.
   * @param  {RunMessageParams} runMessageParams to be sent via a message.
   * @return {Promise} that resolves to a RunResponseMessageParams.
   */
   function sendRunMessage(receiver, runMessageParams) {
-    var messageName = mojo.interfaceControl2.kRunMessageId;
-    var payloadSize = mojo.interfaceControl2.RunMessageParams.encodedSize;
+    var messageName = mojo.interfaceControl.kRunMessageId;
+    var payloadSize = mojo.interfaceControl.RunMessageParams.encodedSize;
     // |requestID| is set to 0, but is later properly set by Router.
     var builder = new internal.MessageV1Builder(messageName,
         payloadSize, internal.kMessageExpectsResponse, 0);
-    builder.encodeStruct(mojo.interfaceControl2.RunMessageParams,
+    builder.encodeStruct(mojo.interfaceControl.RunMessageParams,
                          runMessageParams);
     var message = builder.finish();
 
     return receiver.acceptAndExpectResponse(message).then(acceptRunResponse);
   }
 
   function ControlMessageProxy(receiver) {
     this.receiver_ = receiver;
   }
 
   ControlMessageProxy.prototype.queryVersion = function() {
-    var runMessageParams = new mojo.interfaceControl2.RunMessageParams();
-    runMessageParams.input = new mojo.interfaceControl2.RunInput();
+    var runMessageParams = new mojo.interfaceControl.RunMessageParams();
+    runMessageParams.input = new mojo.interfaceControl.RunInput();
     runMessageParams.input.queryVersion =
-        new mojo.interfaceControl2.QueryVersion();
+        new mojo.interfaceControl.QueryVersion();
 
     return sendRunMessage(this.receiver_, runMessageParams).then(function(
         runResponseMessageParams) {
       return runResponseMessageParams.output.queryVersionResult.version;
     });
   };
 
   ControlMessageProxy.prototype.requireVersion = function(version) {
-    var runOrClosePipeInput = new mojo.interfaceControl2.RunOrClosePipeInput();
+    var runOrClosePipeInput = new mojo.interfaceControl.RunOrClosePipeInput();
     runOrClosePipeInput.requireVersion =
-        new mojo.interfaceControl2.RequireVersion({'version': version});
+        new mojo.interfaceControl.RequireVersion({'version': version});
     var message = constructRunOrClosePipeMessage(runOrClosePipeInput);
     this.receiver_.accept(message);
   };
 
   internal.ControlMessageProxy = ControlMessageProxy;
 })();
 // Copyright 2017 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
@@ -2836,32 +2856,32 @@ mojo.config = {
 
   function validateControlRequestWithoutResponse(message) {
     var messageValidator = new internal.Validator(message);
     var error = messageValidator.validateMessageIsRequestWithoutResponse();
     if (error != internal.validationError.NONE) {
       throw error;
     }
 
-    if (message.getName() != mojo.pipeControl2.kRunOrClosePipeMessageId) {
+    if (message.getName() != mojo.pipeControl.kRunOrClosePipeMessageId) {
       throw new Error("Control message name is not kRunOrClosePipeMessageId");
     }
 
     // Validate payload.
-    error = mojo.pipeControl2.RunOrClosePipeMessageParams.validate(
+    error = mojo.pipeControl.RunOrClosePipeMessageParams.validate(
         messageValidator, message.getHeaderNumBytes());
     if (error != internal.validationError.NONE) {
       throw error;
     }
   }
 
   function runOrClosePipe(message, delegate) {
     var reader = new internal.MessageReader(message);
     var runOrClosePipeMessageParams = reader.decodeStruct(
-        mojo.pipeControl2.RunOrClosePipeMessageParams);
+        mojo.pipeControl.RunOrClosePipeMessageParams);
     var event = runOrClosePipeMessageParams.input
         .peerAssociatedEndpointClosedEvent;
     return delegate.onPeerAssociatedEndpointClosed(event.id,
         event.disconnectReason);
   }
 
   function isPipeControlMessage(message) {
     return !internal.isValidInterfaceId(message.getInterfaceId());
@@ -2883,25 +2903,25 @@ mojo.config = {
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 (function() {
   var internal = mojo.internal;
 
   function constructRunOrClosePipeMessage(runOrClosePipeInput) {
     var runOrClosePipeMessageParams = new
-        mojo.pipeControl2.RunOrClosePipeMessageParams();
+        mojo.pipeControl.RunOrClosePipeMessageParams();
     runOrClosePipeMessageParams.input = runOrClosePipeInput;
 
-    var messageName = mojo.pipeControl2.kRunOrClosePipeMessageId;
+    var messageName = mojo.pipeControl.kRunOrClosePipeMessageId;
     var payloadSize =
-        mojo.pipeControl2.RunOrClosePipeMessageParams.encodedSize;
+        mojo.pipeControl.RunOrClosePipeMessageParams.encodedSize;
 
     var builder = new internal.MessageV0Builder(messageName, payloadSize);
-    builder.encodeStruct(mojo.pipeControl2.RunOrClosePipeMessageParams,
+    builder.encodeStruct(mojo.pipeControl.RunOrClosePipeMessageParams,
                          runOrClosePipeMessageParams);
     var message = builder.finish();
     message.setInterfaceId(internal.kInvalidInterfaceId);
     return message;
   }
 
   function PipeControlMessageProxy(receiver) {
     this.receiver_ = receiver;
@@ -2910,24 +2930,24 @@ mojo.config = {
   PipeControlMessageProxy.prototype.notifyPeerEndpointClosed = function(
       interfaceId, reason) {
     var message = this.constructPeerEndpointClosedMessage(interfaceId, reason);
     this.receiver_.accept(message);
   };
 
   PipeControlMessageProxy.prototype.constructPeerEndpointClosedMessage =
       function(interfaceId, reason) {
-    var event = new mojo.pipeControl2.PeerAssociatedEndpointClosedEvent();
+    var event = new mojo.pipeControl.PeerAssociatedEndpointClosedEvent();
     event.id = interfaceId;
     if (reason) {
-      event.disconnectReason = new mojo.pipeControl2.DisconnectReason({
+      event.disconnectReason = new mojo.pipeControl.DisconnectReason({
           customReason: reason.customReason,
           description: reason.description});
     }
-    var runOrClosePipeInput = new mojo.pipeControl2.RunOrClosePipeInput();
+    var runOrClosePipeInput = new mojo.pipeControl.RunOrClosePipeInput();
     runOrClosePipeInput.peerAssociatedEndpointClosedEvent = event;
     return constructRunOrClosePipeMessage(runOrClosePipeInput);
   };
 
   internal.PipeControlMessageProxy = PipeControlMessageProxy;
 })();
 // Copyright 2014 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
@@ -3091,16 +3111,25 @@ mojo.config = {
   };
 
   Router.prototype.createLocalEndpointHandle = function(
       interfaceId) {
     if (!internal.isValidInterfaceId(interfaceId)) {
       return new internal.InterfaceEndpointHandle();
     }
 
+    // Unless it is the master ID, |interfaceId| is from the remote side and
+    // therefore its namespace bit is supposed to be different than the value
+    // that this router would use.
+    if (!internal.isMasterInterfaceId(interfaceId) &&
+        this.setInterfaceIdNamespaceBit_ ===
+            internal.hasInterfaceIdNamespaceBitSet(interfaceId)) {
+      return new internal.InterfaceEndpointHandle();
+    }
+
     var endpoint = this.endpoints_.get(interfaceId);
 
     if (!endpoint) {
       endpoint = new InterfaceEndpoint(this, interfaceId);
       this.endpoints_.set(interfaceId, endpoint);
 
       check(!endpoint.handleCreated);
 
@@ -3159,18 +3188,16 @@ mojo.config = {
     // Closing the message pipe won't trigger connection error handler.
     // Explicitly call onPipeConnectionError() so that associated endpoints
     // will get notified.
     this.onPipeConnectionError();
   };
 
   Router.prototype.onPeerAssociatedEndpointClosed = function(interfaceId,
       reason) {
-    check(!internal.isMasterInterfaceId(interfaceId) || reason);
-
     var endpoint = this.endpoints_.get(interfaceId);
     if (!endpoint) {
       endpoint = new InterfaceEndpoint(this, interfaceId);
       this.endpoints_.set(interfaceId, endpoint);
     }
 
     if (reason) {
       endpoint.disconnectReason = reason;
@@ -3245,50 +3272,50 @@ mojo.config = {
 
 /**
  * Defines functions for translating between JavaScript strings and UTF8 strings
  * stored in ArrayBuffers. There is much room for optimization in this code if
  * it proves necessary.
  */
 (function() {
   var internal = mojo.internal;
+  var textDecoder = new TextDecoder('utf-8');
+  var textEncoder = new TextEncoder('utf-8');
 
   /**
    * Decodes the UTF8 string from the given buffer.
    * @param {ArrayBufferView} buffer The buffer containing UTF8 string data.
    * @return {string} The corresponding JavaScript string.
    */
   function decodeUtf8String(buffer) {
-    return decodeURIComponent(escape(String.fromCharCode.apply(null, buffer)));
+    return textDecoder.decode(buffer);
   }
 
   /**
    * Encodes the given JavaScript string into UTF8.
    * @param {string} str The string to encode.
    * @param {ArrayBufferView} outputBuffer The buffer to contain the result.
    * Should be pre-allocated to hold enough space. Use |utf8Length| to determine
    * how much space is required.
    * @return {number} The number of bytes written to |outputBuffer|.
    */
   function encodeUtf8String(str, outputBuffer) {
-    var utf8String = unescape(encodeURIComponent(str));
-    if (outputBuffer.length < utf8String.length)
+    const utf8Buffer = textEncoder.encode(str);
+    if (outputBuffer.length < utf8Buffer.length)
       throw new Error("Buffer too small for encodeUtf8String");
-    for (var i = 0; i < outputBuffer.length && i < utf8String.length; i++)
-      outputBuffer[i] = utf8String.charCodeAt(i);
-    return i;
+    outputBuffer.set(utf8Buffer);
+    return utf8Buffer.length;
   }
 
   /**
    * Returns the number of bytes that a UTF8 encoding of the JavaScript string
    * |str| would occupy.
    */
   function utf8Length(str) {
-    var utf8String = unescape(encodeURIComponent(str));
-    return utf8String.length;
+    return textEncoder.encode(str).length;
   }
 
   internal.decodeUtf8String = decodeUtf8String;
   internal.encodeUtf8String = encodeUtf8String;
   internal.utf8Length = utf8Length;
 })();
 // Copyright 2014 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
@@ -3967,35 +3994,31 @@ mojo.config = {
   internal.reportValidationError = reportValidationError;
   internal.isTestingMode = isTestingMode;
   internal.clearTestingMode = clearTestingMode;
 })();
 // Copyright 2014 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-
 'use strict';
 
 (function() {
-  var mojomId = 'mojo/public/interfaces/bindings/new_bindings/interface_control_messages.mojom';
+  var mojomId = 'mojo/public/interfaces/bindings/interface_control_messages.mojom';
   if (mojo.internal.isMojomLoaded(mojomId)) {
     console.warn('The following mojom is loaded multiple times: ' + mojomId);
     return;
   }
   mojo.internal.markMojomLoaded(mojomId);
-
-  // TODO(yzshen): Define these aliases to minimize the differences between the
-  // old/new modes. Remove them when the old mode goes away.
   var bindings = mojo;
   var associatedBindings = mojo;
   var codec = mojo.internal;
   var validator = mojo.internal;
 
-  var exports = mojo.internal.exposeNamespace('mojo.interfaceControl2');
+  var exports = mojo.internal.exposeNamespace('mojo.interfaceControl');
 
 
   var kRunMessageId = 0xFFFFFFFF;
   var kRunOrClosePipeMessageId = 0xFFFFFFFE;
 
   function RunMessageParams(values) {
     this.initDefaults_();
     this.initFields_(values);
@@ -4369,409 +4392,409 @@ mojo.config = {
     encoder.skip(1);
     encoder.skip(1);
   };
 
   function RunInput(value) {
     this.initDefault_();
     this.initValue_(value);
   }
-  
-  
+
+
   RunInput.Tags = {
     queryVersion: 0,
     flushForTesting: 1,
   };
-  
+
   RunInput.prototype.initDefault_ = function() {
     this.$data = null;
     this.$tag = undefined;
   }
-  
+
   RunInput.prototype.initValue_ = function(value) {
     if (value == undefined) {
       return;
     }
-  
+
     var keys = Object.keys(value);
     if (keys.length == 0) {
       return;
     }
-  
+
     if (keys.length > 1) {
       throw new TypeError("You may set only one member on a union.");
     }
-  
+
     var fields = [
         "queryVersion",
         "flushForTesting",
     ];
-  
+
     if (fields.indexOf(keys[0]) < 0) {
       throw new ReferenceError(keys[0] + " is not a RunInput member.");
-  
-    }
-  
+
+    }
+
     this[keys[0]] = value[keys[0]];
   }
   Object.defineProperty(RunInput.prototype, "queryVersion", {
     get: function() {
       if (this.$tag != RunInput.Tags.queryVersion) {
         throw new ReferenceError(
             "RunInput.queryVersion is not currently set.");
       }
       return this.$data;
     },
-  
+
     set: function(value) {
       this.$tag = RunInput.Tags.queryVersion;
       this.$data = value;
     }
   });
   Object.defineProperty(RunInput.prototype, "flushForTesting", {
     get: function() {
       if (this.$tag != RunInput.Tags.flushForTesting) {
         throw new ReferenceError(
             "RunInput.flushForTesting is not currently set.");
       }
       return this.$data;
     },
-  
+
     set: function(value) {
       this.$tag = RunInput.Tags.flushForTesting;
       this.$data = value;
     }
   });
-  
-  
+
+
     RunInput.encode = function(encoder, val) {
       if (val == null) {
         encoder.writeUint64(0);
         encoder.writeUint64(0);
         return;
       }
       if (val.$tag == undefined) {
         throw new TypeError("Cannot encode unions with an unknown member set.");
       }
-    
+
       encoder.writeUint32(16);
       encoder.writeUint32(val.$tag);
       switch (val.$tag) {
         case RunInput.Tags.queryVersion:
           encoder.encodeStructPointer(QueryVersion, val.queryVersion);
           break;
         case RunInput.Tags.flushForTesting:
           encoder.encodeStructPointer(FlushForTesting, val.flushForTesting);
           break;
       }
       encoder.align();
     };
-  
-  
+
+
     RunInput.decode = function(decoder) {
       var size = decoder.readUint32();
       if (size == 0) {
         decoder.readUint32();
         decoder.readUint64();
         return null;
       }
-    
+
       var result = new RunInput();
       var tag = decoder.readUint32();
       switch (tag) {
         case RunInput.Tags.queryVersion:
           result.queryVersion = decoder.decodeStructPointer(QueryVersion);
           break;
         case RunInput.Tags.flushForTesting:
           result.flushForTesting = decoder.decodeStructPointer(FlushForTesting);
           break;
       }
       decoder.align();
-    
+
       return result;
     };
-  
-  
+
+
     RunInput.validate = function(messageValidator, offset) {
       var size = messageValidator.decodeUnionSize(offset);
       if (size != 16) {
         return validator.validationError.INVALID_UNION_SIZE;
       }
-    
+
       var tag = messageValidator.decodeUnionTag(offset);
       var data_offset = offset + 8;
       var err;
       switch (tag) {
         case RunInput.Tags.queryVersion:
           
-    
+
     // validate RunInput.queryVersion
     err = messageValidator.validateStructPointer(data_offset, QueryVersion, false);
     if (err !== validator.validationError.NONE)
         return err;
           break;
         case RunInput.Tags.flushForTesting:
           
-    
+
     // validate RunInput.flushForTesting
     err = messageValidator.validateStructPointer(data_offset, FlushForTesting, false);
     if (err !== validator.validationError.NONE)
         return err;
           break;
       }
-    
+
       return validator.validationError.NONE;
     };
-  
+
   RunInput.encodedSize = 16;
 
   function RunOutput(value) {
     this.initDefault_();
     this.initValue_(value);
   }
-  
-  
+
+
   RunOutput.Tags = {
     queryVersionResult: 0,
   };
-  
+
   RunOutput.prototype.initDefault_ = function() {
     this.$data = null;
     this.$tag = undefined;
   }
-  
+
   RunOutput.prototype.initValue_ = function(value) {
     if (value == undefined) {
       return;
     }
-  
+
     var keys = Object.keys(value);
     if (keys.length == 0) {
       return;
     }
-  
+
     if (keys.length > 1) {
       throw new TypeError("You may set only one member on a union.");
     }
-  
+
     var fields = [
         "queryVersionResult",
     ];
-  
+
     if (fields.indexOf(keys[0]) < 0) {
       throw new ReferenceError(keys[0] + " is not a RunOutput member.");
-  
-    }
-  
+
+    }
+
     this[keys[0]] = value[keys[0]];
   }
   Object.defineProperty(RunOutput.prototype, "queryVersionResult", {
     get: function() {
       if (this.$tag != RunOutput.Tags.queryVersionResult) {
         throw new ReferenceError(
             "RunOutput.queryVersionResult is not currently set.");
       }
       return this.$data;
     },
-  
+
     set: function(value) {
       this.$tag = RunOutput.Tags.queryVersionResult;
       this.$data = value;
     }
   });
-  
-  
+
+
     RunOutput.encode = function(encoder, val) {
       if (val == null) {
         encoder.writeUint64(0);
         encoder.writeUint64(0);
         return;
       }
       if (val.$tag == undefined) {
         throw new TypeError("Cannot encode unions with an unknown member set.");
       }
-    
+
       encoder.writeUint32(16);
       encoder.writeUint32(val.$tag);
       switch (val.$tag) {
         case RunOutput.Tags.queryVersionResult:
           encoder.encodeStructPointer(QueryVersionResult, val.queryVersionResult);
           break;
       }
       encoder.align();
     };
-  
-  
+
+
     RunOutput.decode = function(decoder) {
       var size = decoder.readUint32();
       if (size == 0) {
         decoder.readUint32();
         decoder.readUint64();
         return null;
       }
-    
+
       var result = new RunOutput();
       var tag = decoder.readUint32();
       switch (tag) {
         case RunOutput.Tags.queryVersionResult:
           result.queryVersionResult = decoder.decodeStructPointer(QueryVersionResult);
           break;
       }
       decoder.align();
-    
+
       return result;
     };
-  
-  
+
+
     RunOutput.validate = function(messageValidator, offset) {
       var size = messageValidator.decodeUnionSize(offset);
       if (size != 16) {
         return validator.validationError.INVALID_UNION_SIZE;
       }
-    
+
       var tag = messageValidator.decodeUnionTag(offset);
       var data_offset = offset + 8;
       var err;
       switch (tag) {
         case RunOutput.Tags.queryVersionResult:
           
-    
+
     // validate RunOutput.queryVersionResult
     err = messageValidator.validateStructPointer(data_offset, QueryVersionResult, false);
     if (err !== validator.validationError.NONE)
         return err;
           break;
       }
-    
+
       return validator.validationError.NONE;
     };
-  
+
   RunOutput.encodedSize = 16;
 
   function RunOrClosePipeInput(value) {
     this.initDefault_();
     this.initValue_(value);
   }
-  
-  
+
+
   RunOrClosePipeInput.Tags = {
     requireVersion: 0,
   };
-  
+
   RunOrClosePipeInput.prototype.initDefault_ = function() {
     this.$data = null;
     this.$tag = undefined;
   }
-  
+
   RunOrClosePipeInput.prototype.initValue_ = function(value) {
     if (value == undefined) {
       return;
     }
-  
+
     var keys = Object.keys(value);
     if (keys.length == 0) {
       return;
     }
-  
+
     if (keys.length > 1) {
       throw new TypeError("You may set only one member on a union.");
     }
-  
+
     var fields = [
         "requireVersion",
     ];
-  
+
     if (fields.indexOf(keys[0]) < 0) {
       throw new ReferenceError(keys[0] + " is not a RunOrClosePipeInput member.");
-  
-    }
-  
+
+    }
+
     this[keys[0]] = value[keys[0]];
   }
   Object.defineProperty(RunOrClosePipeInput.prototype, "requireVersion", {
     get: function() {
       if (this.$tag != RunOrClosePipeInput.Tags.requireVersion) {
         throw new ReferenceError(
             "RunOrClosePipeInput.requireVersion is not currently set.");
       }
       return this.$data;
     },
-  
+
     set: function(value) {
       this.$tag = RunOrClosePipeInput.Tags.requireVersion;
       this.$data = value;
     }
   });
-  
-  
+
+
     RunOrClosePipeInput.encode = function(encoder, val) {
       if (val == null) {
         encoder.writeUint64(0);
         encoder.writeUint64(0);
         return;
       }
       if (val.$tag == undefined) {
         throw new TypeError("Cannot encode unions with an unknown member set.");
       }
-    
+
       encoder.writeUint32(16);
       encoder.writeUint32(val.$tag);
       switch (val.$tag) {
         case RunOrClosePipeInput.Tags.requireVersion:
           encoder.encodeStructPointer(RequireVersion, val.requireVersion);
           break;
       }
       encoder.align();
     };
-  
-  
+
+
     RunOrClosePipeInput.decode = function(decoder) {
       var size = decoder.readUint32();
       if (size == 0) {
         decoder.readUint32();
         decoder.readUint64();
         return null;
       }
-    
+
       var result = new RunOrClosePipeInput();
       var tag = decoder.readUint32();
       switch (tag) {
         case RunOrClosePipeInput.Tags.requireVersion:
           result.requireVersion = decoder.decodeStructPointer(RequireVersion);
           break;
       }
       decoder.align();
-    
+
       return result;
     };
-  
-  
+
+
     RunOrClosePipeInput.validate = function(messageValidator, offset) {
       var size = messageValidator.decodeUnionSize(offset);
       if (size != 16) {
         return validator.validationError.INVALID_UNION_SIZE;
       }
-    
+
       var tag = messageValidator.decodeUnionTag(offset);
       var data_offset = offset + 8;
       var err;
       switch (tag) {
         case RunOrClosePipeInput.Tags.requireVersion:
           
-    
+
     // validate RunOrClosePipeInput.requireVersion
     err = messageValidator.validateStructPointer(data_offset, RequireVersion, false);
     if (err !== validator.validationError.NONE)
         return err;
           break;
       }
-    
+
       return validator.validationError.NONE;
     };
-  
+
   RunOrClosePipeInput.encodedSize = 16;
   exports.kRunMessageId = kRunMessageId;
   exports.kRunOrClosePipeMessageId = kRunOrClosePipeMessageId;
   exports.RunMessageParams = RunMessageParams;
   exports.RunResponseMessageParams = RunResponseMessageParams;
   exports.QueryVersion = QueryVersion;
   exports.QueryVersionResult = QueryVersionResult;
   exports.FlushForTesting = FlushForTesting;
@@ -4779,35 +4802,31 @@ mojo.config = {
   exports.RequireVersion = RequireVersion;
   exports.RunInput = RunInput;
   exports.RunOutput = RunOutput;
   exports.RunOrClosePipeInput = RunOrClosePipeInput;
 })();// Copyright 2014 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-
 'use strict';
 
 (function() {
-  var mojomId = 'mojo/public/interfaces/bindings/new_bindings/pipe_control_messages.mojom';
+  var mojomId = 'mojo/public/interfaces/bindings/pipe_control_messages.mojom';
   if (mojo.internal.isMojomLoaded(mojomId)) {
     console.warn('The following mojom is loaded multiple times: ' + mojomId);
     return;
   }
   mojo.internal.markMojomLoaded(mojomId);
-
-  // TODO(yzshen): Define these aliases to minimize the differences between the
-  // old/new modes. Remove them when the old mode goes away.
   var bindings = mojo;
   var associatedBindings = mojo;
   var codec = mojo.internal;
   var validator = mojo.internal;
 
-  var exports = mojo.internal.exposeNamespace('mojo.pipeControl2');
+  var exports = mojo.internal.exposeNamespace('mojo.pipeControl');
 
 
   var kRunOrClosePipeMessageId = 0xFFFFFFFE;
 
   function RunOrClosePipeMessageParams(values) {
     this.initDefaults_();
     this.initFields_(values);
   }
@@ -4889,17 +4908,16 @@ mojo.config = {
       {version: 0, numBytes: 24}
     ];
     err = messageValidator.validateStructVersion(offset, kVersionSizes);
     if (err !== validator.validationError.NONE)
         return err;
 
 
 
-    
     // validate DisconnectReason.description
     err = messageValidator.validateStringPointer(offset + codec.kStructHeaderSize + 8, false)
     if (err !== validator.validationError.NONE)
         return err;
 
     return validator.validationError.NONE;
   };
 
@@ -4957,17 +4975,16 @@ mojo.config = {
       {version: 0, numBytes: 24}
     ];
     err = messageValidator.validateStructVersion(offset, kVersionSizes);
     if (err !== validator.validationError.NONE)
         return err;
 
 
 
-    
     // validate PeerAssociatedEndpointClosedEvent.disconnectReason
     err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 8, DisconnectReason, true);
     if (err !== validator.validationError.NONE)
         return err;
 
     return validator.validationError.NONE;
   };
 
@@ -4998,132 +5015,132 @@ mojo.config = {
     encoder.skip(1);
     encoder.encodeStructPointer(DisconnectReason, val.disconnectReason);
   };
 
   function RunOrClosePipeInput(value) {
     this.initDefault_();
     this.initValue_(value);
   }
-  
-  
+
+
   RunOrClosePipeInput.Tags = {
     peerAssociatedEndpointClosedEvent: 0,
   };
-  
+
   RunOrClosePipeInput.prototype.initDefault_ = function() {
     this.$data = null;
     this.$tag = undefined;
   }
-  
+
   RunOrClosePipeInput.prototype.initValue_ = function(value) {
     if (value == undefined) {
       return;
     }
-  
+
     var keys = Object.keys(value);
     if (keys.length == 0) {
       return;
     }
-  
+
     if (keys.length > 1) {
       throw new TypeError("You may set only one member on a union.");
     }
-  
+
     var fields = [
         "peerAssociatedEndpointClosedEvent",
     ];
-  
+
     if (fields.indexOf(keys[0]) < 0) {
       throw new ReferenceError(keys[0] + " is not a RunOrClosePipeInput member.");
-  
-    }
-  
+
+    }
+
     this[keys[0]] = value[keys[0]];
   }
   Object.defineProperty(RunOrClosePipeInput.prototype, "peerAssociatedEndpointClosedEvent", {
     get: function() {
       if (this.$tag != RunOrClosePipeInput.Tags.peerAssociatedEndpointClosedEvent) {
         throw new ReferenceError(
             "RunOrClosePipeInput.peerAssociatedEndpointClosedEvent is not currently set.");
       }
       return this.$data;
     },
-  
+
     set: function(value) {
       this.$tag = RunOrClosePipeInput.Tags.peerAssociatedEndpointClosedEvent;
       this.$data = value;
     }
   });
-  
-  
+
+
     RunOrClosePipeInput.encode = function(encoder, val) {
       if (val == null) {
         encoder.writeUint64(0);
         encoder.writeUint64(0);
         return;
       }
       if (val.$tag == undefined) {
         throw new TypeError("Cannot encode unions with an unknown member set.");
       }
-    
+
       encoder.writeUint32(16);
       encoder.writeUint32(val.$tag);
       switch (val.$tag) {
         case RunOrClosePipeInput.Tags.peerAssociatedEndpointClosedEvent:
           encoder.encodeStructPointer(PeerAssociatedEndpointClosedEvent, val.peerAssociatedEndpointClosedEvent);
           break;
       }
       encoder.align();
     };
-  
-  
+
+
     RunOrClosePipeInput.decode = function(decoder) {
       var size = decoder.readUint32();
       if (size == 0) {
         decoder.readUint32();
         decoder.readUint64();
         return null;
       }
-    
+
       var result = new RunOrClosePipeInput();
       var tag = decoder.readUint32();
       switch (tag) {
         case RunOrClosePipeInput.Tags.peerAssociatedEndpointClosedEvent:
           result.peerAssociatedEndpointClosedEvent = decoder.decodeStructPointer(PeerAssociatedEndpointClosedEvent);
           break;
       }
       decoder.align();
-    
+
       return result;
     };
-  
-  
+
+
     RunOrClosePipeInput.validate = function(messageValidator, offset) {
       var size = messageValidator.decodeUnionSize(offset);
       if (size != 16) {
         return validator.validationError.INVALID_UNION_SIZE;
       }
-    
+
       var tag = messageValidator.decodeUnionTag(offset);
       var data_offset = offset + 8;
       var err;
       switch (tag) {
         case RunOrClosePipeInput.Tags.peerAssociatedEndpointClosedEvent:
           
-    
+
     // validate RunOrClosePipeInput.peerAssociatedEndpointClosedEvent
     err = messageValidator.validateStructPointer(data_offset, PeerAssociatedEndpointClosedEvent, false);
     if (err !== validator.validationError.NONE)
         return err;
           break;
       }
-    
+
       return validator.validationError.NONE;
     };
-  
+
   RunOrClosePipeInput.encodedSize = 16;
   exports.kRunOrClosePipeMessageId = kRunOrClosePipeMessageId;
   exports.RunOrClosePipeMessageParams = RunOrClosePipeMessageParams;
   exports.DisconnectReason = DisconnectReason;
   exports.PeerAssociatedEndpointClosedEvent = PeerAssociatedEndpointClosedEvent;
   exports.RunOrClosePipeInput = RunOrClosePipeInput;
 })();
\ No newline at end of file
--- a/testing/web-platform/tests/resources/chromium/string16.mojom.js
+++ b/testing/web-platform/tests/resources/chromium/string16.mojom.js
@@ -1,32 +1,33 @@
 // Copyright 2014 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-
 'use strict';
-if ((typeof mojo !== 'undefined')  && mojo.internal && mojo.config) {
 
 (function() {
   var mojomId = 'mojo/public/mojom/base/string16.mojom';
   if (mojo.internal.isMojomLoaded(mojomId)) {
     console.warn('The following mojom is loaded multiple times: ' + mojomId);
     return;
   }
   mojo.internal.markMojomLoaded(mojomId);
-
-  // TODO(yzshen): Define these aliases to minimize the differences between the
-  // old/new modes. Remove them when the old mode goes away.
   var bindings = mojo;
   var associatedBindings = mojo;
   var codec = mojo.internal;
   var validator = mojo.internal;
 
-  var exports = mojo.internal.exposeNamespace('mojo.common.mojom');
+  var exports = mojo.internal.exposeNamespace('mojoBase.mojom');
+  var big_buffer$ =
+      mojo.internal.exposeNamespace('mojoBase.mojom');
+  if (mojo.config.autoLoadMojomDeps) {
+    mojo.internal.loadMojomIfNecessary(
+        'mojo/public/mojom/base/big_buffer.mojom', 'big_buffer.mojom.js');
+  }
 
 
 
   function String16(values) {
     this.initDefaults_();
     this.initFields_(values);
   }
 
@@ -50,17 +51,16 @@ if ((typeof mojo !== 'undefined')  && mo
     var kVersionSizes = [
       {version: 0, numBytes: 16}
     ];
     err = messageValidator.validateStructVersion(offset, kVersionSizes);
     if (err !== validator.validationError.NONE)
         return err;
 
 
-    
     // validate String16.data
     err = messageValidator.validateArrayPointer(offset + codec.kStructHeaderSize + 0, 2, codec.Uint16, false, [0], 0);
     if (err !== validator.validationError.NONE)
         return err;
 
     return validator.validationError.NONE;
   };
 
@@ -76,84 +76,66 @@ if ((typeof mojo !== 'undefined')  && mo
   };
 
   String16.encode = function(encoder, val) {
     var packed;
     encoder.writeUint32(String16.encodedSize);
     encoder.writeUint32(0);
     encoder.encodeArrayPointer(codec.Uint16, val.data);
   };
-  exports.String16 = String16;
-})();
-}
-
-if ((typeof mojo === 'undefined') || !mojo.internal || !mojo.config) {
-
-define("mojo/public/mojom/base/string16.mojom", [
-    "mojo/public/js/associated_bindings",
-    "mojo/public/js/bindings",
-    "mojo/public/js/codec",
-    "mojo/public/js/core",
-    "mojo/public/js/validator",
-], function(associatedBindings, bindings, codec, core, validator) {
-  var exports = {};
-
-  function String16(values) {
+  function BigString16(values) {
     this.initDefaults_();
     this.initFields_(values);
   }
 
 
-  String16.prototype.initDefaults_ = function() {
+  BigString16.prototype.initDefaults_ = function() {
     this.data = null;
   };
-  String16.prototype.initFields_ = function(fields) {
+  BigString16.prototype.initFields_ = function(fields) {
     for(var field in fields) {
         if (this.hasOwnProperty(field))
           this[field] = fields[field];
     }
   };
 
-  String16.validate = function(messageValidator, offset) {
+  BigString16.validate = function(messageValidator, offset) {
     var err;
     err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);
     if (err !== validator.validationError.NONE)
         return err;
 
     var kVersionSizes = [
-      {version: 0, numBytes: 16}
+      {version: 0, numBytes: 24}
     ];
     err = messageValidator.validateStructVersion(offset, kVersionSizes);
     if (err !== validator.validationError.NONE)
         return err;
 
 
-    
-    // validate String16.data
-    err = messageValidator.validateArrayPointer(offset + codec.kStructHeaderSize + 0, 2, codec.Uint16, false, [0], 0);
+    // validate BigString16.data
+    err = messageValidator.validateUnion(offset + codec.kStructHeaderSize + 0, big_buffer$.BigBuffer, false);
     if (err !== validator.validationError.NONE)
         return err;
 
     return validator.validationError.NONE;
   };
 
-  String16.encodedSize = codec.kStructHeaderSize + 8;
+  BigString16.encodedSize = codec.kStructHeaderSize + 16;
 
-  String16.decode = function(decoder) {
+  BigString16.decode = function(decoder) {
     var packed;
-    var val = new String16();
+    var val = new BigString16();
     var numberOfBytes = decoder.readUint32();
     var version = decoder.readUint32();
-    val.data = decoder.decodeArrayPointer(codec.Uint16);
+    val.data = decoder.decodeStruct(big_buffer$.BigBuffer);
     return val;
   };
 
-  String16.encode = function(encoder, val) {
+  BigString16.encode = function(encoder, val) {
     var packed;
-    encoder.writeUint32(String16.encodedSize);
+    encoder.writeUint32(BigString16.encodedSize);
     encoder.writeUint32(0);
-    encoder.encodeArrayPointer(codec.Uint16, val.data);
+    encoder.encodeStruct(big_buffer$.BigBuffer, val.data);
   };
   exports.String16 = String16;
-
-  return exports;
-});
-}
\ No newline at end of file
+  exports.BigString16 = BigString16;
+})();
\ No newline at end of file
--- a/testing/web-platform/tests/resources/chromium/url.mojom.js
+++ b/testing/web-platform/tests/resources/chromium/url.mojom.js
@@ -71,9 +71,9 @@
 
   Url.encode = function(encoder, val) {
     var packed;
     encoder.writeUint32(Url.encodedSize);
     encoder.writeUint32(0);
     encoder.encodeStruct(codec.String, val.url);
   };
   exports.Url = Url;
-})();
+})();
\ No newline at end of file
--- a/testing/web-platform/tests/resources/chromium/web_usb_service.mojom.js
+++ b/testing/web-platform/tests/resources/chromium/web_usb_service.mojom.js
@@ -18,21 +18,27 @@
 
   var exports = mojo.internal.exposeNamespace('blink.mojom');
   var device$ =
       mojo.internal.exposeNamespace('device.mojom');
   if (mojo.config.autoLoadMojomDeps) {
     mojo.internal.loadMojomIfNecessary(
         'device/usb/public/mojom/device.mojom', '../../../../../device/usb/public/mojom/device.mojom.js');
   }
-  var device_manager$ =
+  var device_enumeration_options$ =
       mojo.internal.exposeNamespace('device.mojom');
   if (mojo.config.autoLoadMojomDeps) {
     mojo.internal.loadMojomIfNecessary(
-        'device/usb/public/mojom/device_manager.mojom', '../../../../../device/usb/public/mojom/device_manager.mojom.js');
+        'device/usb/public/mojom/device_enumeration_options.mojom', '../../../../../device/usb/public/mojom/device_enumeration_options.mojom.js');
+  }
+  var device_manager_client$ =
+      mojo.internal.exposeNamespace('device.mojom');
+  if (mojo.config.autoLoadMojomDeps) {
+    mojo.internal.loadMojomIfNecessary(
+        'device/usb/public/mojom/device_manager_client.mojom', '../../../../../device/usb/public/mojom/device_manager_client.mojom.js');
   }
 
 
 
   function WebUsbService_GetDevices_Params(values) {
     this.initDefaults_();
     this.initFields_(values);
   }
@@ -231,39 +237,39 @@
       {version: 0, numBytes: 16}
     ];
     err = messageValidator.validateStructVersion(offset, kVersionSizes);
     if (err !== validator.validationError.NONE)
         return err;
 
 
     // validate WebUsbService_GetPermission_Params.deviceFilters
-    err = messageValidator.validateArrayPointer(offset + codec.kStructHeaderSize + 0, 8, new codec.PointerTo(device_manager$.UsbDeviceFilter), false, [0], 0);
+    err = messageValidator.validateArrayPointer(offset + codec.kStructHeaderSize + 0, 8, new codec.PointerTo(device_enumeration_options$.UsbDeviceFilter), false, [0], 0);
     if (err !== validator.validationError.NONE)
         return err;
 
     return validator.validationError.NONE;
   };
 
   WebUsbService_GetPermission_Params.encodedSize = codec.kStructHeaderSize + 8;
 
   WebUsbService_GetPermission_Params.decode = function(decoder) {
     var packed;
     var val = new WebUsbService_GetPermission_Params();
     var numberOfBytes = decoder.readUint32();
     var version = decoder.readUint32();
-    val.deviceFilters = decoder.decodeArrayPointer(new codec.PointerTo(device_manager$.UsbDeviceFilter));
+    val.deviceFilters = decoder.decodeArrayPointer(new codec.PointerTo(device_enumeration_options$.UsbDeviceFilter));
     return val;
   };
 
   WebUsbService_GetPermission_Params.encode = function(encoder, val) {
     var packed;
     encoder.writeUint32(WebUsbService_GetPermission_Params.encodedSize);
     encoder.writeUint32(0);
-    encoder.encodeArrayPointer(new codec.PointerTo(device_manager$.UsbDeviceFilter), val.deviceFilters);
+    encoder.encodeArrayPointer(new codec.PointerTo(device_enumeration_options$.UsbDeviceFilter), val.deviceFilters);
   };
   function WebUsbService_GetPermission_ResponseParams(values) {
     this.initDefaults_();
     this.initFields_(values);
   }
 
 
   WebUsbService_GetPermission_ResponseParams.prototype.initDefaults_ = function() {
@@ -600,9 +606,9 @@
     validateRequest: validateWebUsbServiceRequest,
     validateResponse: validateWebUsbServiceResponse,
   };
   WebUsbServiceStub.prototype.validator = validateWebUsbServiceRequest;
   WebUsbServiceProxy.prototype.validator = validateWebUsbServiceResponse;
   exports.WebUsbService = WebUsbService;
   exports.WebUsbServicePtr = WebUsbServicePtr;
   exports.WebUsbServiceAssociatedPtr = WebUsbServiceAssociatedPtr;
-})();
+})();
\ No newline at end of file
--- a/testing/web-platform/tests/webusb/resources/usb-helpers.js
+++ b/testing/web-platform/tests/webusb/resources/usb-helpers.js
@@ -37,20 +37,22 @@ let loadChromiumResources = Promise.reso
     // Do nothing on non-Chromium-based browsers or when the Mojo bindings are
     // not present in the global namespace.
     return;
   }
 
   let chain = Promise.resolve();
   [
     '/resources/chromium/mojo_bindings.js',
+    '/resources/chromium/big_buffer.mojom.js',
     '/resources/chromium/string16.mojom.js',
     '/resources/chromium/url.mojom.js',
     '/resources/chromium/device.mojom.js',
-    '/resources/chromium/device_manager.mojom.js',
+    '/resources/chromium/device_enumeration_options.mojom.js',
+    '/resources/chromium/device_manager_client.mojom.js',
     '/resources/chromium/web_usb_service.mojom.js',
     '/resources/chromium/webusb-test.js',
   ].forEach(path => {
     // Use importScripts for workers.
     if (typeof document === 'undefined') {
       chain = chain.then(() => importScripts(path));
       return;
     }