How to use assert_own_property method in wpt

Best JavaScript code snippet using wpt

getusermedia_conformance_test.js

Source:getusermedia_conformance_test.js Github

copy

Full Screen

...20var mediaStreamTest = async_test('4.2 MediaStream');21function verifyMediaStream(stream) {22 // TODO(kjellander): Add checks for default values where applicable.23 test(function () {24 assert_own_property(stream, 'id');25 assert_true(typeof stream.id === 'string');26 assert_readonly(stream, 'id');27 }, '[MediaStream] id attribute');28 test(function () {29 assert_inherits(stream, 'getAudioTracks');30 assert_true(typeof stream.getAudioTracks === 'function');31 }, '[MediaStream] getAudioTracks function');32 test(function () {33 assert_inherits(stream, 'getVideoTracks');34 assert_true(typeof stream.getVideoTracks === 'function');35 }, '[MediaStream] getVideoTracks function');36 test(function () {37 assert_inherits(stream, 'getTrackById');38 assert_true(typeof stream.getTrackById === 'function');39 }, '[MediaStream] getTrackById function');40 test(function () {41 assert_inherits(stream, 'addTrack');42 assert_true(typeof stream.addTrack === 'function');43 }, '[MediaStream] addTrack function');44 test(function () {45 assert_inherits(stream, 'removeTrack');46 assert_true(typeof stream.removeTrack === 'function');47 }, '[MediaStream] removeTrack function');48 test(function () {49 // Missing in Chrome.50 assert_inherits(stream, 'clone');51 assert_true(typeof stream.clone === 'function');52 }, '[MediaStream] clone function');53 test(function () {54 assert_own_property(stream, 'ended');55 assert_true(typeof stream.ended === 'boolean');56 assert_readonly(stream, 'ended');57 }, '[MediaStream] ended attribute');58 test(function () {59 assert_own_property(stream, 'onended');60 assert_true(stream.onended === null);61 }, '[MediaStream] onended EventHandler');62 test(function () {63 assert_own_property(stream, 'onaddtrack');64 assert_true(stream.onaddtrack === null);65 }, '[MediaStream] onaddtrack EventHandler');66 test(function () {67 assert_own_property(stream, 'onremovetrack');68 assert_true(stream.onremovetrack === null);69 }, '[MediaStream] onremovetrack EventHandler');70}71mediaStreamTest.step(function() {72 var okCallback = mediaStreamTest.step_func(function (stream) {73 verifyMediaStream(stream);74 var videoTracks = stream.getVideoTracks();75 assert_true(videoTracks.length > 0);76 // Verify event handlers are working.77 stream.onaddtrack = onAddTrackCallback78 stream.onremovetrack = onRemoveTrackCallback79 stream.removeTrack(videoTracks[0]);80 stream.addTrack(videoTracks[0]);81 mediaStreamTest.done();82 });83 var onAddTrackCallback = mediaStreamTest.step_func(function () {84 // TODO(kjellander): verify number of tracks.85 mediaStreamTest.done();86 });87 var onRemoveTrackCallback = mediaStreamTest.step_func(function () {88 // TODO(kjellander): verify number of tracks.89 mediaStreamTest.done();90 });91 invokeGetUserMedia(mediaStreamTest, okCallback);;92});93// 4.3 MediaStreamTrack.94var mediaStreamTrackTest = async_test('4.3 MediaStreamTrack');95function verifyTrack(type, track) {96 test(function () {97 assert_own_property(track, 'kind');98 assert_readonly(track, 'kind');99 assert_true(typeof track.kind === 'string',100 'kind is an object (DOMString)');101 }, '[MediaStreamTrack (' + type + ')] kind attribute');102 test(function () {103 assert_own_property(track, 'id');104 assert_readonly(track, 'id');105 assert_true(typeof track.id === 'string',106 'id is an object (DOMString)');107 }, '[MediaStreamTrack (' + type + ')] id attribute');108 test(function () {109 assert_own_property(track, 'label');110 assert_readonly(track, 'label');111 assert_true(typeof track.label === 'string',112 'label is an object (DOMString)');113 }, '[MediaStreamTrack (' + type + ')] label attribute');114 test(function () {115 assert_own_property(track, 'enabled');116 assert_true(typeof track.enabled === 'boolean');117 assert_true(track.enabled, 'enabled property must be true initially');118 }, '[MediaStreamTrack (' + type + ')] enabled attribute');119 test(function () {120 // Missing in Chrome.121 assert_own_property(track, 'muted');122 assert_readonly(track, 'muted');123 assert_true(typeof track.muted === 'boolean');124 assert_false(track.muted, 'muted property must be false initially');125 }, '[MediaStreamTrack (' + type + ')] muted attribute');126 test(function () {127 assert_own_property(track, 'onmute');128 assert_true(track.onmute === null);129 }, '[MediaStreamTrack (' + type + ')] onmute EventHandler');130 test(function () {131 assert_own_property(track, 'onunmute');132 assert_true(track.onunmute === null);133 }, '[MediaStreamTrack (' + type + ')] onunmute EventHandler');134 test(function () {135 // Missing in Chrome.136 assert_own_property(track, '_readonly');137 assert_readonly(track, '_readonly');138 assert_true(typeof track._readonly === 'boolean');139 }, '[MediaStreamTrack (' + type + ')] _readonly attribute');140 test(function () {141 // Missing in Chrome.142 assert_own_property(track, 'remote');143 assert_readonly(track, 'remote');144 assert_true(typeof track.remote === 'boolean');145 }, '[MediaStreamTrack (' + type + ')] remote attribute');146 test(function () {147 assert_own_property(track, 'readyState');148 assert_readonly(track, 'readyState');149 assert_true(typeof track.readyState === 'string');150 // TODO(kjellander): verify the initial state.151 }, '[MediaStreamTrack (' + type + ')] readyState attribute');152 test(function () {153 // Missing in Chrome.154 assert_own_property(track, 'onstarted');155 assert_true(track.onstarted === null);156 }, '[MediaStreamTrack (' + type + ')] onstarted EventHandler');157 test(function () {158 assert_own_property(track, 'onended');159 assert_true(track.onended === null);160 }, '[MediaStreamTrack (' + type + ')] onended EventHandler');161 test(function () {162 // Missing in Chrome.163 assert_inherits(track, 'getSourceInfos');164 assert_true(typeof track.getSourceInfos === 'function');165 }, '[MediaStreamTrack (' + type + ')]: getSourceInfos function');166 test(function () {167 // Missing in Chrome.168 assert_inherits(track, 'constraints');169 assert_true(typeof track.constraints === 'function');170 }, '[MediaStreamTrack (' + type + ')]: constraints function');171 test(function () {172 // Missing in Chrome.173 assert_inherits(track, 'states');174 assert_true(typeof track.states === 'function');175 }, '[MediaStreamTrack (' + type + ')]: states function');176 test(function () {177 // Missing in Chrome.178 assert_inherits(track, 'capabilities');179 assert_true(typeof track.capabilities === 'function');180 }, '[MediaStreamTrack (' + type + ')]: capabilities function');181 test(function () {182 // Missing in Chrome.183 assert_inherits(track, 'applyConstraints');184 assert_true(typeof track.applyConstraints === 'function');185 }, '[MediaStreamTrack (' + type + ')]: applyConstraints function');186 test(function () {187 // Missing in Chrome.188 assert_own_property(track, 'onoverconstrained');189 assert_true(track.onoverconstrained === null);190 }, '[MediaStreamTrack (' + type + ')] onoverconstrained EventHandler');191 test(function () {192 // Missing in Chrome.193 assert_inherits(track, 'clone');194 assert_true(typeof track.clone === 'function');195 }, '[MediaStreamTrack (' + type + ')] clone function');196 test(function () {197 // Missing in Chrome.198 assert_inherits(track, 'stop');199 assert_true(typeof track.stop === 'function');200 }, '[MediaStreamTrack (' + type + ')] stop function');201};202mediaStreamTrackTest.step(function() {203 var okCallback = mediaStreamTrackTest.step_func(function (stream) {204 verifyTrack('audio', stream.getAudioTracks()[0]);205 verifyTrack('video', stream.getVideoTracks()[0]);206 mediaStreamTrackTest.done();207 });208 invokeGetUserMedia(mediaStreamTrackTest, okCallback);209});210mediaStreamTrackTest.step(function() {211 var okCallback = mediaStreamTrackTest.step_func(function (stream) {212 // Verify event handlers are working.213 var track = stream.getVideoTracks()[0];214 track.onended = onendedCallback215 track.stop();216 mediaStreamTrackTest.done();217 });218 var onendedCallback = mediaStreamTrackTest.step_func(function () {219 assert_true(track.ended);220 mediaStreamTrackTest.done();221 });222 invokeGetUserMedia(mediaStreamTrackTest, okCallback);223});224// 4.4 MediaStreamTrackEvent tests.225var mediaStreamTrackEventTest = async_test('4.4 MediaStreamTrackEvent');226mediaStreamTrackEventTest.step(function() {227 var okCallback = mediaStreamTrackEventTest.step_func(function (stream) {228 // TODO(kjellander): verify attributes229 mediaStreamTrackEventTest.done();230 });231 invokeGetUserMedia(mediaStreamTrackEventTest, okCallback);232});233// 4.5 Video and Audio Tracks tests.234var avTracksTest = async_test('4.5 Video and Audio Tracks');235avTracksTest.step(function() {236 var okCallback = avTracksTest.step_func(function (stream) {237 // TODO(kjellander): verify attributes238 avTracksTest.done();239 });240 invokeGetUserMedia(avTracksTest, okCallback);241});242// 5. The model: sources, sinks, constraints, and states243// 6. Source states244// 6.1 Dictionary MediaSourceStates Members245// 7. Source capabilities246// 7.1 Dictionary CapabilityRange Members247// 7.2 CapabilityList array248// 7.3 Dictionary AllVideoCapabilities Members249// 7.4 Dictionary AllAudioCapabilities Members250// 8. URL tests.251var createObjectURLTest = async_test('8.1 URL createObjectURL method');252createObjectURLTest.step(function() {253 var okCallback = createObjectURLTest.step_func(function (stream) {254 var url = webkitURL.createObjectURL(stream);255 assert_true(typeof url === 'string');256 createObjectURLTest.done();257 });258 invokeGetUserMedia(createObjectURLTest, okCallback);259});260// 9. MediaStreams as Media Elements.261var mediaElementsTest = async_test('9. MediaStreams as Media Elements');262function verifyVideoTagWithStream(videoTag) {263 test(function () {264 assert_equals(videoTag.buffered.length, 0);265 }, '[Video tag] buffered attribute');266 test(function () {267 // Attempts to alter currentTime shall be ignored.268 assert_true(videoTag.currentTime >= 0);269 assert_throws('InvalidStateError',270 function () { videoTag.currentTime = 1234; },271 'Attempts to modify currentTime shall throw ' +272 'InvalidStateError');273 }, '[Video tag] currentTime attribute');274 test(function () {275 assert_equals(videoTag.duration, Infinity, 'videoTag.duration');276 }, '[Video tag] duration attribute');277 test(function () {278 assert_false(videoTag.seeking, 'videoTag.seeking');279 }, '[Video tag] seeking attribute');280 test(function () {281 assert_equals(videoTag.defaultPlaybackRate, 1.0);282 assert_throws('DOMException',283 function () { videoTag.defaultPlaybackRate = 2.0; },284 'Attempts to alter videoTag.defaultPlaybackRate MUST fail');285 }, '[Video tag] defaultPlaybackRate attribute');286 test(function () {287 assert_equals(videoTag.playbackRate, 1.0);288 assert_throws('DOMException',289 function () { videoTag.playbackRate = 2.0; },290 'Attempts to alter videoTag.playbackRate MUST fail');291 }, '[Video tag] playbackRate attribute');292 test(function () {293 assert_equals(videoTag.played.length, 1, 'videoTag.played.length');294 assert_equals(videoTag.played.start(0), 0);295 assert_true(videoTag.played.end(0) >= videoTag.currentTime);296 }, '[Video tag] played attribute');297 test(function () {298 assert_equals(videoTag.seekable.length, 0);299 assert_equals(videoTag.seekable.start(), videoTag.currentTime);300 assert_equals(videoTag.seekable.end(), videoTag.currentTime);301 assert_equals(videoTag.startDate, NaN, 'videoTag.startDate');302 }, '[Video tag] seekable attribute');303 test(function () {304 assert_false(videoTag.loop);305 }, '[Video tag] loop attribute');306};307mediaElementsTest.step(function() {308 var okCallback = mediaElementsTest.step_func(function (stream) {309 var videoTag = document.getElementById('local-view');310 // Call the polyfill wrapper to attach the media stream to this element.311 attachMediaStream(videoTag, stream);312 verifyVideoTagWithStream(videoTag);313 mediaElementsTest.done();314 });315 invokeGetUserMedia(mediaElementsTest, okCallback);316});317// 11. Obtaining local multimedia content.318// 11.1 NavigatorUserMedia.319var getUserMediaTest = async_test('11.1 NavigatorUserMedia');320getUserMediaTest.step(function() {321 var okCallback = getUserMediaTest.step_func(function (stream) {322 assert_true(stream !== null);323 getUserMediaTest.done();324 });325 // boolean parameters, without failure callback:326 getUserMedia({ video: true, audio: true }, okCallback);327 getUserMedia({ video: true, audio: false }, okCallback);328 getUserMedia({ video: false, audio: true }, okCallback);329 // boolean parameters, with failure callback:330 getUserMedia({ video: true, audio: true }, okCallback,331 failedCallback(getUserMediaTest));332 getUserMedia({ video: true, audio: false }, okCallback,333 failedCallback(getUserMediaTest));334 getUserMedia({ video: false, audio: true }, okCallback,335 failedCallback(getUserMediaTest));336});337// 11.2 MediaStreamConstraints.338var constraintsTest = async_test('11.2 MediaStreamConstraints');339constraintsTest.step(function() {340 var okCallback = constraintsTest.step_func(function (stream) {341 assert_true(stream !== null);342 constraintsTest.done();343 });344 // Constraints on video.345 // See http://webrtc.googlecode.com/svn/trunk/samples/js/demos/html/constraints-and-stats.html346 // for more examples of constraints.347 var constraints = {};348 constraints.audio = true;349 constraints.video = { mandatory: {}, optional: [] };350 constraints.video.mandatory.minWidth = 640;351 constraints.video.mandatory.minHeight = 480;352 constraints.video.mandatory.minFrameRate = 15;353 getUserMedia(constraints, okCallback, failedCallback(constraintsTest));354});355// 11.3 NavigatorUserMediaSuccessCallback.356var successCallbackTest =357 async_test('11.3 NavigatorUserMediaSuccessCallback');358successCallbackTest.step(function() {359 var okCallback = successCallbackTest.step_func(function (stream) {360 assert_true(stream !== null);361 successCallbackTest.done();362 });363 invokeGetUserMedia(successCallbackTest, okCallback);364});365// 11.4 NavigatorUserMediaError and NavigatorUserMediaErrorCallback.366var errorCallbackTest = async_test('11.4 NavigatorUserMediaError and ' +367 'NavigatorUserMediaErrorCallback');368errorCallbackTest.step(function() {369 var okCallback = errorCallbackTest.step_func(function (stream) {370 assert_unreached('Should not get a success callback');371 });372 var errorCallback = errorCallbackTest.step_func(function (error) {373 assert_own_property(error, 'name');374 assert_readonly(error.name);375 assert_true(typeof error.name === 'string');376 assert_equals(error.name, 'ConstraintNotSatisfiedError', 'error.name');377 errorCallbackTest.done();378 });379 // Setting both audio and video to false triggers an error callback.380 // TODO(kjellander): Figure out if there's a way in the spec to trigger an381 // error callback.382 // TODO(kjellander): Investigate why the error callback is not called when383 // false/false is provided in Chrome.384 getUserMedia({ video: false, audio: false }, okCallback, errorCallback);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var obj = {a: 1, b: 2, c: 3};2assert_own_property(obj, 'a');3assert_own_property(obj, 'b');4assert_own_property(obj, 'c');5assert_own_property(obj, 'd');6var obj = {a: 1, b: 2, c: 3};7assert_own_property(obj, 'a');8assert_own_property(obj, 'b');9assert_own_property(obj, 'c');10assert_own_property(obj, 'd');11var obj = {a: 1, b: 2, c: 3};12assert_own_property(obj, 'a');13assert_own_property(obj, 'b');14assert_own_property(obj, 'c');15assert_own_property(obj, 'd');16var obj = {a: 1, b: 2, c: 3};17assert_own_property(obj, 'a');18assert_own_property(obj, 'b');19assert_own_property(obj, 'c');20assert_own_property(obj, 'd');21var obj = {a: 1, b: 2, c: 3};22assert_own_property(obj, 'a');23assert_own_property(obj, 'b');24assert_own_property(obj, 'c');25assert_own_property(obj, 'd');26var obj = {a: 1, b: 2, c: 3};27assert_own_property(obj, 'a');28assert_own_property(obj, 'b');29assert_own_property(obj, 'c');30assert_own_property(obj, 'd');31var obj = {a: 1, b: 2, c: 3};32assert_own_property(obj, 'a');33assert_own_property(obj, 'b');34assert_own_property(obj, 'c');35assert_own_property(obj, 'd');36var obj = {a:

Full Screen

Using AI Code Generation

copy

Full Screen

1const assert_own_property = wpt.assert_own_property;2const assert_equals = wpt.assert_equals;3const assert_true = wpt.assert_true;4const assert_false = wpt.assert_false;5const assert_throws = wpt.assert_throws;6const assert_class_string = wpt.assert_class_string;7const assert_array_equals = wpt.assert_array_equals;8const assert_object_equals = wpt.assert_object_equals;9const assert_unreached = wpt.assert_unreached;10const assert_approx_equals = wpt.assert_approx_equals;11const assert_in_array = wpt.assert_in_array;12const assert_regexp_match = wpt.assert_regexp_match;13const assert_idl_attribute = wpt.assert_idl_attribute;14const assert_idl_attribute_equals = wpt.assert_idl_attribute_equals;15const assert_idl_attribute_array = wpt.assert_idl_attribute_array;16const assert_idl_attributes = wpt.assert_idl_attributes;17const assert_readonly = wpt.assert_readonly;18const assert_not_readonly = wpt.assert_not_readonly;19const assert_throws_js = wpt.assert_throws_js;20const assert_throws_dom = wpt.assert_throws_dom;

Full Screen

Using AI Code Generation

copy

Full Screen

1var assert_own_property = function(obj, prop, msg) {2 if (typeof msg === 'undefined') {3 msg = "assert_own_property: " + prop + " not found in " + JSON.stringify(obj);4 }5 assert_in_array(prop, Object.getOwnPropertyNames(obj), msg);6};7var assert_equals = function(actual, expected, msg) {8 if (typeof msg === 'undefined') {9 msg = "assert_equals: " + actual + " != " + expected;10 }11 assert(actual === expected, msg);12};13var assert_true = function(actual, msg) {14 if (typeof msg === 'undefined') {15 msg = "assert_true: " + actual + " is not true";16 }17 assert(actual, msg);18};19var assert_false = function(actual, msg) {20 if (typeof msg === 'undefined') {21 msg = "assert_false: " + actual + " is not false";22 }23 assert(!actual, msg);24};25var assert_array_equals = function(actual, expected, msg) {26 if (typeof msg === 'undefined') {27 msg = "assert_array_equals: " + JSON.stringify(actual) + " != " + JSON.stringify(expected);28 }29 assert(actual.length === expected.length, msg);30 for (var i = 0; i < actual.length; i++) {31 assert_equals(actual[i], expected[i], msg);32 }33};34var assert_in_array = function(actual, expected, msg) {35 if (typeof msg === 'undefined') {36 msg = "assert_in_array: " + JSON.stringify(actual) + " not in " + JSON.stringify(expected);37 }38 assert(expected.indexOf(actual) !== -1, msg);39};40var assert_throws = function(expected, f, msg) {41 if (typeof msg === 'undefined') {42 msg = "assert_throws: " + expected + " not thrown by " + f;43 }44 var threw = false;45 try {46 f();47 } catch (e) {48 threw = true;49 assert_equals(e

Full Screen

Using AI Code Generation

copy

Full Screen

1assert_own_property(obj, prop, msg);2assert.deepStrictEqual(obj.hasOwnProperty(prop), true, msg);3assert_inherits(obj, prop, msg);4assert.deepStrictEqual(obj.hasOwnProperty(prop), true, msg);5assert.deepStrictEqual(typeof obj[prop], 'function', msg);6assert_readonly(obj, prop, msg);7assert.deepStrictEqual(obj.hasOwnProperty(prop), true, msg);8assert.deepStrictEqual(Object.getOwnPropertyDescriptor(obj, prop).writable, false, msg);9assert_throws(error, func, msg);10assert.throws(func, error, msg);11assert_throws_dom(error, func, msg);12assert.throws(func, error, msg);13assert_throws_exactly(error, func, msg);14assert.throws(func, error, msg);15assert_throws_js(error, func, msg);16assert.throws(func, error, msg);17assert_throws_exactly(error, func, msg);18assert.throws(func, error, msg);19assert_throws_exactly(error, func, msg);20assert.throws(func, error, msg);21assert_throws_exactly(error

Full Screen

Using AI Code Generation

copy

Full Screen

1assert_own_property(object, property, message, stackStartFunction)2var obj = {a: 1, b: 2};3assert_own_property(obj, "a", "obj has property a");4assert_throws(code, func, message, stackStartFunction)5assert_throws("TypeError", function() { throw new TypeError("foo"); });6assert_unreached(message)7assert_unreached("This code is unreachable");8promise_rejects(test, reason, promise, message)9promise_rejects_dom(test, name, code, promise, message)10promise_rejects_exactly(test, reason, promise, message)11promise_rejects_unreached(test, reason, promise, message)

Full Screen

Using AI Code Generation

copy

Full Screen

1test(function() {2 assert_own_property(object, property, message);3}, "test description");4test(function() {5 assert_readonly(object, property, message);6}, "test description");7test(function() {8 assert_throws(code, func, description);9}, "test description");10test(function() {11 assert_throws_dom(code, func, description);12}, "test description");13test(function() {14 assert_true(value, message);15}, "test description");16test(function() {17 assert_unreached(message);18}, "test description");19test(function() {20 assert_equals(object, property, message);21}, "test description");22test(function() {23 assert_false(value, message);24}, "test description");

Full Screen

Using AI Code Generation

copy

Full Screen

1assert_own_property(this, "prototype", "prototype property of object is not accessible");2assert_own_property(this, "constructor", "constructor property of object is not accessible");3assert_own_property(this, "__proto__", "__proto__ property of object is not accessible");4assert_own_property(this, "toString", "toString property of object is not accessible");5assert_own_property(this, "valueOf", "valueOf property of object is not accessible");6assert_own_property(this, "hasOwnProperty", "hasOwnProperty property of object is not accessible");7assert_own_property(this, "isPrototypeOf", "isPrototypeOf property of object is not accessible");8assert_own_property(this, "propertyIsEnumerable", "propertyIsEnumerable property of object is not accessible");9assert_own_property(this, "toLocaleString", "toLocaleString property of object is not accessible");10assert_own_property(this, "__defineGetter__", "__defineGetter__ property of object is not accessible");

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful