Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/resources/audit.js

Issue 2805773002: Implement ownProperty() and inheritFrom() assertions in should() (Closed)
Patch Set: Addressing feedback Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 /** 6 /**
7 * @fileOverview WebAudio layout test utility library. Built around W3C's 7 * @fileOverview WebAudio layout test utility library. Built around W3C's
8 * testharness.js. Includes asynchronous test task manager, 8 * testharness.js. Includes asynchronous test task manager,
9 * assertion utilities. 9 * assertion utilities.
10 * @dependency testharness.js 10 * @dependency testharness.js
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 * should(true, 'The message is').message('truthful!', 'false!'); 970 * should(true, 'The message is').message('truthful!', 'false!');
971 * 971 *
972 * @result 972 * @result
973 * "PASS The message is truthful!" 973 * "PASS The message is truthful!"
974 */ 974 */
975 message(passDetail, failDetail) { 975 message(passDetail, failDetail) {
976 return this._assert(this._actual, 976 return this._assert(this._actual,
977 '${actual} ' + passDetail, 977 '${actual} ' + passDetail,
978 '${actual} ' + failDetail); 978 '${actual} ' + failDetail);
979 } 979 }
980
981 /**
982 * Check if |expected| property is truly owned by |actual| object.
983 *
984 * @example
985 * should(BaseAudioContext.prototype,
986 * 'BaseAudioContext.prototype').haveOwnProperty('createGain');
987 *
988 * @result
989 * "PASS BaseAudioContext.prototype has an own property of
990 * 'createGain'."
991 */
992 haveOwnProperty () {
993 this._processArguments(arguments);
994
995 return this._assert(
996 this._actual.hasOwnProperty(this._expected),
997 '${actual} has an own property of "${expected}".',
998 '${actual} does not own the property of "${expected}".');
999 }
1000
1001
1002 /**
1003 * Check if |expected| property is not owned by |actual| object.
1004 *
1005 * @example
1006 * should(BaseAudioContext.prototype,
1007 * 'BaseAudioContext.prototype')
1008 * .notHaveOwnProperty('startRendering');
1009 *
1010 * @result
1011 * "PASS BaseAudioContext.prototype does not have an own property of
1012 * 'startRendering'."
1013 */
1014 notHaveOwnProperty () {
1015 this._processArguments(arguments);
1016
1017 return this._assert(
1018 !this._actual.hasOwnProperty(this._expected),
1019 '${actual} does not have an own property of "${expected}".',
1020 '${actual} has an own the property of "${expected}".')
1021 }
1022
1023
1024 /**
1025 * Check if an object is inherited from a class. This looks up the entire
1026 * prototype chain of a given object and tries to find a match.
1027 *
1028 * @example
1029 * should(sourceNode, 'A buffer source node')
1030 * .inheritFrom('AudioScheduledSourceNode');
1031 *
1032 * @result
1033 * "PASS A buffer source node inherits from 'AudioScheduledSourceNode'."
1034 */
1035 inheritFrom () {
1036 this._processArguments(arguments);
1037
1038 let prototypes = [];
1039 let currentPrototype = Object.getPrototypeOf(this._actual);
1040 while (currentPrototype) {
1041 prototypes.push(currentPrototype.constructor.name);
1042 currentPrototype = Object.getPrototypeOf(currentPrototype);
1043 }
1044
1045 return this._assert(
1046 prototypes.includes(this._expected),
1047 '${actual} inherits from "${expected}".',
1048 '${actual} does not inherit from "${expected}".');
1049 }
980 } 1050 }
981 1051
982 1052
983 // Task Class state enum. 1053 // Task Class state enum.
984 const TaskState = { 1054 const TaskState = {
985 PENDING: 0, 1055 PENDING: 0,
986 STARTED: 1, 1056 STARTED: 1,
987 FINISHED: 2 1057 FINISHED: 2
988 }; 1058 };
989 1059
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 1352
1283 /** 1353 /**
1284 * Load file from a given URL and pass ArrayBuffer to the following promise. 1354 * Load file from a given URL and pass ArrayBuffer to the following promise.
1285 * See |loadFileFromUrl| method for the detail. 1355 * See |loadFileFromUrl| method for the detail.
1286 */ 1356 */
1287 loadFileFromUrl: loadFileFromUrl 1357 loadFileFromUrl: loadFileFromUrl
1288 1358
1289 }; 1359 };
1290 1360
1291 })(); 1361 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698