Index: third_party/WebKit/LayoutTests/webaudio/resources/audit.js |
diff --git a/third_party/WebKit/LayoutTests/webaudio/resources/audit.js b/third_party/WebKit/LayoutTests/webaudio/resources/audit.js |
index d2946161efbb1f2cd2f707a8d6487db5145ddee8..0ed38805798a3c2959c31154eb7c36f7b53b697e 100644 |
--- a/third_party/WebKit/LayoutTests/webaudio/resources/audit.js |
+++ b/third_party/WebKit/LayoutTests/webaudio/resources/audit.js |
@@ -964,6 +964,54 @@ window.Audit = (function () { |
'${actual} ' + passDetail, |
'${actual} ' + failDetail); |
} |
+ |
+ /** |
+ * Check if |expected| property is truly owned by |actual| object. |
+ * |
+ * @example |
+ * should(BaseAudioContext.prototype, |
+ * 'BaseAudioContext.prototype').ownProperty('createGain'); |
+ * |
+ * @result |
+ * "PASS BaseAudioContext.prototype has an own property of |
+ * 'createGain'." |
+ */ |
+ ownProperty() { |
Raymond Toy
2017/04/06 23:13:14
ownProperty or beOwnPropertyOf (as mentioned in th
hongchan
2017/04/07 15:55:36
I think this is cleaner. Let me know if you think
Raymond Toy
2017/04/07 16:10:58
Maybe
should(obj).haveOwnProperty(property)
? b
hongchan
2017/04/07 17:22:16
I llke haveOwnProperty().
|
+ this._processArguments(arguments); |
+ |
+ return this._assert( |
+ this._actual.hasOwnProperty(this._expected), |
+ '${actual} has an own property of "${expected}".', |
+ '${actual} does not own the property of "${expected}".'); |
+ } |
+ |
+ |
+ /** |
+ * Check if an object is inherited from a class. This looks up the entire |
+ * prototype chain of a given object and tries to find a match. |
+ * |
+ * @example |
+ * should(sourceNode, 'A buffer source node') |
+ * .inheritFrom('AudioScheduledSourceNode'); |
+ * |
+ * @result |
+ * "PASS A buffer source node inherits from 'AudioScheduledSourceNode'." |
+ */ |
+ inheritFrom() { |
+ this._processArguments(arguments); |
+ |
+ let prototypes = []; |
+ let currentPrototype = Object.getPrototypeOf(this._actual); |
+ while (currentPrototype) { |
+ prototypes.push(currentPrototype.constructor.name); |
+ currentPrototype = Object.getPrototypeOf(currentPrototype); |
+ } |
+ |
+ return this._assert( |
+ prototypes.includes(this._expected), |
+ '${actual} inherits from "${expected}".', |
+ '${actual} does not inherit from "${expected}".'); |
+ } |
} |