summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/resources/interfaces.js
blob: eb00df65ff3b7b709a2c603cd7be21f765ec5f40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function verify_interface(name, instance, attributes) {
  assert_true(name in self,
              name + ' should be an defined type');
  if (instance) {
    assert_true(instance instanceof self[name],
                instance + ' should be an instance of ' + name);
    Object.keys(attributes || {}).forEach(function(attribute) {
        var type = attributes[attribute];
        assert_true(attribute in instance,
                    attribute + ' should be an attribute of ' + name);
        assert_equals(typeof instance[attribute], type,
                      attribute + ' should be of type ' + type);
      });
  }
}