How to use expect_config method in wpt

Best JavaScript code snippet using wpt

requestmediakeysystemaccess.js

Source:requestmediakeysystemaccess.js Github

copy

Full Screen

...25 assert_subset(actual[property], expected[property], path + '.' + property);26 }27 }28 }29 function expect_config(keySystem, configurations, expectedConfiguration, testname) {30 promise_test(function(test) {31 return navigator.requestMediaKeySystemAccess(keySystem, configurations).then(function(a) {32 assert_subset(a.getConfiguration(), expectedConfiguration, testname + ': ');33 });34 }, testname);35 }36 // Tests for Key System.37 expect_error('', [{}], 'TypeError', 'Empty Key System');38 expect_error('com.example.unsupported', [{}], 'NotSupportedError', 'Unsupported Key System');39 expect_error(config.keysystem + '.', [{}], 'NotSupportedError', 'Key System ending in "."');40 expect_error(config.keysystem.toUpperCase(), [{}], 'NotSupportedError', 'Capitalized Key System');41 expect_error(config.keysystem + '\u028F', [{}], 'NotSupportedError', 'Non-ASCII Key System');42 // Parent of Clear Key not supported.43 expect_error(config.keysystem.match(/^(.*?)\./)[1], [{}], 'NotSupportedError', 'Root domain of Key System alone');44 expect_error(config.keysystem.match(/^(.*?)\./)[0], [{}], 'NotSupportedError', 'Root domain of Key System, with dot');45 expect_error(config.keysystem.match(/^(.*?\..*?)\./)[1], [{}], 'NotSupportedError', 'Domain of Key System along');46 expect_error(config.keysystem.match(/^(.*?\..*?)\./)[0], [{}], 'NotSupportedError', 'Domain of Key System, with dot');47 // Child of Clear Key not supported.48 expect_error(config.keysystem+'.foo', [{}], 'NotSupportedError', 'Child of Key System');49 // Prefixed Clear Key not supported.50 expect_error('webkit-'+config.keysystem, [{}], 'NotSupportedError', 'Prefixed Key System');51 // Incomplete names.52 expect_error(config.keysystem.substr(0,7)+config.keysystem.substr(8), [{}], 'NotSupportedError', 'Missing characters in middle of Key System name');53 expect_error(config.keysystem.substr(0,config.keysystem.length-1), [{}], 'NotSupportedError', 'Missing characters at end of Key System name');54 // Spaces in key system name not supported.55 expect_error(' '+config.keysystem, [{}], 'NotSupportedError', 'Leading space in Key System name');56 expect_error(config.keysystem.substr(0,6) + ' ' + config.keysystem.substr(6), [{}], 'NotSupportedError', 'Extra space in Key System name');57 expect_error(config.keysystem + ' ', [{}], 'NotSupportedError', 'Trailing space in Key System name');58 // Extra dots in key systems names not supported.59 expect_error('.' + config.keysystem, [{}], 'NotSupportedError', 'Leading dot in Key System name');60 expect_error(config.keysystem.substr(0,6) + '.' + config.keysystem.substr(6), [{}], 'NotSupportedError', 'Extra dot in middle of Key System name');61 expect_error(config.keysystem + '.', [{}], 'NotSupportedError', 'Trailing dot in Key System name');62 // Key system name is case sensitive.63 if (config.keysystem !== config.keysystem.toUpperCase()) {64 expect_error(config.keysystem.toUpperCase(), [{}], 'NotSupportedError', 'Key System name is case sensitive');65 }66 if (config.keysystem !== config.keysystem.toLowerCase()) {67 expect_error(config.keysystem.toLowerCase(), [{}], 'NotSupportedError', 'Key System name is case sensitive');68 }69 // Tests for trivial configurations.70 expect_error(config.keysystem, [], 'TypeError', 'Empty supportedConfigurations');71 expect_error(config.keysystem, [{}], 'NotSupportedError', 'Empty configuration');72 // Various combinations of supportedConfigurations.73 expect_config(config.keysystem, [{74 initDataTypes: [config.initDataType],75 audioCapabilities: [{contentType: config.audioType}],76 videoCapabilities: [{contentType: config.videoType}],77 }], {78 initDataTypes: [config.initDataType],79 audioCapabilities: [{contentType: config.audioType}],80 videoCapabilities: [{contentType: config.videoType}],81 }, 'Basic supported configuration');82 expect_config(config.keysystem, [{83 initDataTypes: ['fakeidt', config.initDataType],84 audioCapabilities: [{contentType: 'audio/fake'}, {contentType: config.audioType}],85 videoCapabilities: [{contentType: 'video/fake'}, {contentType: config.videoType}],86 }], {87 initDataTypes: [config.initDataType],88 audioCapabilities: [{contentType: config.audioType}],89 videoCapabilities: [{contentType: config.videoType}],90 }, 'Partially supported configuration');91 expect_config(config.keysystem, [{92 audioCapabilities: [{contentType: config.audioType}],93 }], {94 audioCapabilities: [{contentType: config.audioType}],95 }, 'Supported audio codec');96 expect_config(config.keysystem, [{97 audioCapabilities: [{contentType: config.audioType.replace(/^(.*?);(.*)/, "$1; $2")}],98 }], {99 audioCapabilities: [{contentType: config.audioType.replace(/^(.*?);(.*)/, "$1; $2")}],100 }, 'ContentType formatting must be preserved');101 expect_error(config.keysystem, [{102 audioCapabilities: [{contentType: 'audio/webm; codecs=fake'}],103 }], 'NotSupportedError', 'Unsupported audio codec (%audiocontenttype)');104 expect_error(config.keysystem, [{105 audioCapabilities: [{contentType: 'video/webm; codecs=fake'}],106 }], 'NotSupportedError', 'Unsupported video codec (%videocontenttype)');107 expect_error(config.keysystem, [{108 audioCapabilities: [109 {contentType: 'audio/webm; codecs=mp4a'},110 {contentType: 'audio/webm; codecs=mp4a.40.2'}111 ],112 }], 'NotSupportedError', 'Mismatched audio container/codec (%audiocontenttype)');113 expect_error(config.keysystem, [{114 audioCapabilities: [{contentType: config.videoType}],115 }], 'NotSupportedError', 'Video codec specified in audio field (%audiocontenttype)');116 expect_error(config.keysystem, [{117 videoCapabilities: [{contentType: config.audioType}],118 }], 'NotSupportedError', 'Audio codec specified in video field (%videocontenttype)');119 expect_error(config.keysystem, [{120 audioCapabilities: [121 {contentType: 'audio/webm; codecs=avc1'},122 {contentType: 'audio/webm; codecs=avc1.42e01e'}123 ],124 }], 'NotSupportedError', 'Mismatched audio container/codec (%audiocontenttype)');125 expect_error(config.keysystem, [{126 audioCapabilities: [127 {contentType: 'audio/mp4; codecs=vorbis'}128 ],129 }], 'NotSupportedError', 'Mismatched audio container/codec (%audiocontenttype)');130 expect_config(config.keysystem, [{131 initDataTypes: ['fakeidt'],132 videoCapabilities: [{contentType: config.videoType}]133 }, {134 initDataTypes: [config.initDataType],135 videoCapabilities: [{contentType: config.videoType}]136 }137 ], {138 initDataTypes: [config.initDataType],139 videoCapabilities: [{contentType: config.videoType}]140 }, 'Two configurations, one supported');141 expect_config(config.keysystem, [{142 initDataTypes: [config.initDataType],143 videoCapabilities: [{contentType: config.videoType}]144 }, {145 videoCapabilities: [{contentType: config.videoType}]146 }147 ], {148 initDataTypes: [config.initDataType],149 videoCapabilities: [{contentType: config.videoType}]150 }, 'Two configurations, both supported');151 // Audio MIME type does not support video codecs.152 expect_error(config.keysystem, [{153 audioCapabilities: [154 {contentType: 'audio/webm; codecs="vp8,vorbis"'},155 {contentType: 'audio/webm; codecs="vorbis, vp8"'},156 {contentType: 'audio/webm; codecs="vp8"'}157 ],158 }], 'NotSupportedError', 'Audio MIME type does not support video codecs (webm) (%audiocontenttype)');159 expect_error(config.keysystem, [{160 audioCapabilities: [161 {contentType: 'audio/mp4; codecs="avc1"'},162 {contentType: 'audio/mp4; codecs="avc1.4d401e"'},163 ],164 }], 'NotSupportedError', 'Audio MIME type does not support video codecs (mp4) (%audiocontenttype)');165 // Video MIME type does not support audio codecs.166 expect_error(config.keysystem, [{167 videoCapabilities: [168 {contentType: 'video/webm; codecs="vp8,vorbis"'},169 {contentType: 'video/webm; codecs="vorbis, vp8"'},170 {contentType: 'video/webm; codecs="vorbis"'}171 ],172 }], 'NotSupportedError', 'Video MIME type does not support audio codecs (webm) (%videocontenttype)');173 expect_error(config.keysystem, [{174 videoCapabilities: [175 {contentType: 'video/mp4; codecs="mp4a"'},176 {contentType: 'video/mp4; codecs="mp4a.40.2"'}177 ],178 }], 'NotSupportedError', 'Video MIME type does not support audio codecs (mp4) (%videocontenttype)');179 // WebM does not support AVC1/AAC.180 expect_error(config.keysystem, [{181 audioCapabilities: [182 {contentType: 'audio/webm; codecs="aac"'},183 {contentType: 'audio/webm; codecs="avc1"'},184 {contentType: 'audio/webm; codecs="vp8,aac"'}185 ],186 }], 'NotSupportedError', 'WebM audio does not support AVC1/AAC (%audiocontenttype)');187 expect_error(config.keysystem, [{188 videoCapabilities: [189 {contentType: 'video/webm; codecs="aac"'},190 {contentType: 'video/webm; codecs="avc1"'},191 {contentType: 'video/webm; codecs="vp8,aac"'}192 ],193 }], 'NotSupportedError', 'WebM video does not support AVC1/AAC (%videocontenttype)');194 // Extra space is allowed in contentType.195 expect_config(config.keysystem, [{196 videoCapabilities: [{contentType: ' ' + config.videoType}],197 }], {198 videoCapabilities: [{contentType: ' ' + config.videoType}],199 }, 'Leading space in contentType');200 expect_config(config.keysystem, [{201 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?);(.*)/, "$1 ;$2")}],202 }], {203 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?);(.*)/, "$1 ;$2")}],204 }, 'Space before ; in contentType');205 expect_config(config.keysystem, [{206 videoCapabilities: [{contentType: config.videoType + ' '}],207 }], {208 videoCapabilities: [{contentType: config.videoType + ' '}],209 }, 'Trailing space in contentType');210 expect_config(config.keysystem, [{211 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?codecs=\")(.*)/, "$1 $2")}],212 }], {213 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?codecs=\")(.*)/, "$1 $2")}],214 }, 'Space at start of codecs parameter');215 expect_config(config.keysystem, [{216 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?codecs=\".*)\"/, "$1 \"")}],217 }], {218 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?codecs=\".*)\"/, "$1 \"")}],219 }, 'Space at end of codecs parameter');220 // contentType is not case sensitive (except the codec names).221 expect_config(config.keysystem, [{222 videoCapabilities: [{contentType: 'V' + config.videoType.substr(1)}],223 }], {224 videoCapabilities: [{contentType: 'V' + config.videoType.substr(1)}],225 }, 'Video/' );226 expect_config(config.keysystem, [{227 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?)c(odecs.*)/, "$1C$2")}],228 }], {229 videoCapabilities: [{contentType: config.videoType.replace( /^(.*?)c(odecs.*)/, "$1C$2")}],230 }, 'Codecs=');231 var t = config.videoType.match(/(.*?)(;.*)/);232 expect_config(config.keysystem, [{233 videoCapabilities: [{contentType: t[1].toUpperCase() + t[2]}],234 }], {235 videoCapabilities: [{contentType: t[1].toUpperCase() + t[2]}],236 }, 'Upper case MIME type');237 t = config.videoType.match(/(.*?)codecs(.*)/);238 expect_config(config.keysystem, [{239 videoCapabilities: [{contentType: t[1] + 'CODECS' + t[2]}],240 }], {241 videoCapabilities: [{contentType: t[1] + 'CODECS' + t[2]}],242 }, 'CODECS=');243 // Unrecognized attributes are not allowed.244 expect_error(config.keysystem, [{245 videoCapabilities: [{contentType: 'video/webm; foo="bar"'}],246 }], 'NotSupportedError', 'Unrecognized foo with webm (%videocontenttype)');247 expect_error(config.keysystem, [{248 videoCapabilities: [{contentType: 'video/mp4; foo="bar"'}],249 }], 'NotSupportedError', 'Unrecognized foo with mp4 (%videocontenttype)');250 expect_error(config.keysystem, [{251 videoCapabilities: [{contentType: config.videoType + '; foo="bar"'}],252 }], 'NotSupportedError', 'Unrecognized foo with codecs (%videocontenttype)');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt-api');2var expect = require('chai').expect;3var expect_config = wpt.expect_config;4var wpt_config = wpt.wpt_config;5describe('wpt-api', function () {6 describe('expect_config', function () {7 it('should return false if no config is passed', function () {8 expect(expect_config()).to.be.false;9 });10 it('should return false if no config.key is passed', function () {11 expect(expect_config({})).to.be.false;12 });13 it('should return false if no config.location is passed', function () {14 expect(expect_config({key: 'abc'})).to.be.false;15 });16 it('should return false if no config.location is passed', function () {17 expect(expect_config({key: 'abc', location: 'Dulles:Chrome'})).to.be.false;18 });19 it('should return true if all required values are passed', function () {20 });21 });22});23describe('wpt-api', function () {24 describe('wpt_config', function () {25 it('should return false if no config is passed', function () {26 expect(wpt_config()).to.be.false;27 });28 it('should return false if no config.key is passed', function () {29 expect(wpt_config({})).to.be.false;30 });31 it('should return false if no config.location is passed', function () {32 expect(wpt_config({key: 'abc'})).to.be.false;33 });34 it('should return false if no config.location is passed', function () {35 expect(wpt_config({key: 'abc', location: 'Dulles:Chrome'})).to.be.false;36 });37 it('should return true if all required values are passed', function () {38 });39 });40});41var wpt = require('wpt-api');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.8b6a1d6f4a9b1c4c8d4f4a4d2e2c4a4');3wpt.expect_config('location', 'Dulles:Chrome', function(err, data) {4 if (err) return console.error(err);5 console.log(data);6});7> expect_config(testId, config, callback)8var wpt = require('webpagetest');9var wpt = new WebPageTest('www.webpagetest.org', 'A.8b6a1d6f4a9b1c4c8d4f4a4d2e2c4a4');10wpt.expect_config('150911_3A_2e0f0f3c3c3c3c3c3c3c3c3c3c3c3c3c', 'location', 'Dulles:Chrome', function(err, data) {11 if (err) return console.error(err);12 console.log(data);13});14> get_testers(callback)15var wpt = require('webpagetest');16var wpt = new WebPageTest('www.webpagetest.org', 'A.8b6a1d6f4a9b1c4c8d4f4a4d2e2c4a4');17wpt.get_testers(function(err, data) {18 if (err) return console.error(err);19 console.log(data);20});21> get_locations(callback)

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