Best JavaScript code snippet using playwright-internal
initializable.js
Source:initializable.js
1import _chai from 'isotropic-dev-dependencies/lib/chai.js';2import _domain from 'domain'; // eslint-disable-line isotropic/node/no-deprecated-api -- TODO: Find a way to implement this test without a domain.3import _Error from 'isotropic-error';4import _Initializable from '../js/initializable.js';5import _later from 'isotropic-later';6import _make from 'isotropic-make';7import _mocha from 'isotropic-dev-dependencies/lib/mocha.js';8_mocha.describe('_Initializable', function () {9 this.timeout(377);10 _mocha.it('should construct initializable objects', () => {11 _chai.expect(_Initializable).to.be.a('function');12 const initializable = new _Initializable();13 _chai.expect(initializable).to.be.an.instanceOf(_Initializable);14 _chai.expect(initializable).to.have.property('initialized', true);15 initializable.destroy();16 _chai.expect(initializable.initialized).to.be.undefined;17 });18 _mocha.it('should be an initializable object factory', () => {19 _chai.expect(_Initializable).to.be.a('function');20 const initializable = _Initializable();21 _chai.expect(initializable).to.be.an.instanceOf(_Initializable);22 _chai.expect(initializable).to.have.property('initialized', true);23 initializable.destroy();24 _chai.expect(initializable.initialized).to.be.undefined;25 });26 _mocha.it('should pass initialization arguments', () => {27 let initializeExecuted = false;28 const CustomInitializable = _make(_Initializable, {29 _initialize (...args) {30 _chai.expect(args).to.deep.equal([31 'a',32 'b',33 'c'34 ]);35 initializeExecuted = true;36 }37 });38 CustomInitializable('a', 'b', 'c');39 _chai.expect(initializeExecuted).to.be.true;40 });41 _mocha.it('should allow construction without initialization', () => {42 const initializable = _Initializable({43 initialize: false44 });45 _chai.expect(initializable).to.have.property('initialized', false);46 initializable.destroy('never initialized');47 _chai.expect(initializable.initialized).to.be.undefined;48 });49 _mocha.it('should allow observation of initialization', () => {50 const initializable = _Initializable({51 initialize: false52 }),53 subscriptionsExecuted = [];54 _chai.expect(initializable).to.have.property('initialized', false);55 initializable._initialize = function (...args) {56 _chai.expect(args).to.deep.equal([57 'a',58 'b',59 'c'60 ]);61 subscriptionsExecuted.push('defaultInitialize');62 };63 initializable._initializeComplete = function (...args) {64 _chai.expect(args).to.deep.equal([65 'a',66 'b',67 'c'68 ]);69 subscriptionsExecuted.push('defaultInitializeComplete');70 Reflect.apply(_Initializable.prototype._initializeComplete, this, args);71 };72 initializable.after('initialize', () => {73 _chai.expect(initializable).to.have.property('initialized', true);74 subscriptionsExecuted.push('afterInitialize');75 });76 initializable.on('initialize', () => {77 _chai.expect(initializable).to.have.property('initialized', false);78 subscriptionsExecuted.push('onInitialize');79 });80 initializable.on('initializeComplete', () => {81 _chai.expect(initializable).to.have.property('initialized', true);82 subscriptionsExecuted.push('onInitializeComplete');83 });84 initializable.initialize('a', 'b', 'c');85 _chai.expect(initializable).to.have.property('initialized', true);86 _chai.expect(subscriptionsExecuted).to.deep.equal([87 'onInitialize',88 'defaultInitialize',89 'onInitializeComplete',90 'defaultInitializeComplete',91 'afterInitialize'92 ]);93 });94 _mocha.it('should call every inherited _initialize method', () => {95 let z;96 const initializeExecuted = [],97 A = _make({98 _initialize () {99 _chai.expect(this).to.equal(z);100 initializeExecuted.push('A');101 }102 }),103 B = _make({104 _initialize () {105 _chai.expect(this).to.equal(z);106 initializeExecuted.push('B');107 }108 }),109 C = _make({110 _initialize () {111 _chai.expect(this).to.equal(z);112 initializeExecuted.push('C');113 }114 }),115 X = _make(_Initializable, [116 A117 ], {118 _initialize () {119 _chai.expect(this).to.equal(z);120 initializeExecuted.push('X');121 }122 }),123 Y = _make(X, [124 B125 ], {126 _initialize () {127 _chai.expect(this).to.equal(z);128 initializeExecuted.push('Y');129 }130 }),131 Z = _make(Y, [132 C133 ], {134 _initialize () {135 _chai.expect(this).to.equal(z);136 initializeExecuted.push('Z');137 }138 });139 z = Z({140 initialize: false141 });142 z._initialize = () => {143 initializeExecuted.push('z');144 };145 z.initialize();146 _chai.expect(initializeExecuted).to.deep.equal([147 'A',148 'X',149 'B',150 'Y',151 'C',152 'Z',153 'z'154 ]);155 });156 _mocha.it('should initialize mixins in definition order', () => {157 let e;158 const initializeExecuted = [],159 A = _make({160 _initialize () {161 _chai.expect(this).to.equal(e);162 initializeExecuted.push('A');163 }164 }),165 B = _make({166 _initialize () {167 _chai.expect(this).to.equal(e);168 initializeExecuted.push('B');169 }170 }),171 C = _make({172 _initialize () {173 _chai.expect(this).to.equal(e);174 initializeExecuted.push('C');175 }176 }),177 D = _make({178 _initialize () {179 _chai.expect(this).to.equal(e);180 initializeExecuted.push('D');181 }182 }),183 E = _make(_Initializable, [184 A,185 B,186 C,187 D188 ], {189 _initialize () {190 _chai.expect(this).to.equal(e);191 initializeExecuted.push('E');192 }193 });194 e = E({195 initialize: false196 });197 e._initialize = () => {198 initializeExecuted.push('e');199 };200 e.initialize();201 _chai.expect(initializeExecuted).to.deep.equal([202 'A',203 'B',204 'C',205 'D',206 'E',207 'e'208 ]);209 });210 _mocha.it('should not call inherited _initialize methods on _doNotInitialize objects', () => {211 const initializeExecuted = [],212 A = _make({213 _initialize () {214 initializeExecuted.push('A');215 }216 }),217 B = _make({218 _initialize () {219 initializeExecuted.push('B');220 }221 }),222 C = _make({223 _initialize () {224 initializeExecuted.push('C');225 }226 }),227 X = _make(_Initializable, [228 A229 ], {230 _doNotInitialize: A,231 _initialize () {232 initializeExecuted.push('X');233 }234 }),235 Y = _make(X, [236 B237 ], {238 _initialize () {239 initializeExecuted.push('Y');240 }241 }),242 Z = _make(Y, [243 C244 ], {245 _doNotInitialize: B,246 _initialize () {247 initializeExecuted.push('Z');248 }249 }),250 z = Z({251 initialize: false252 });253 z._doNotInitialize = z;254 z._initialize = () => {255 initializeExecuted.push('z');256 };257 z.initialize();258 _chai.expect(initializeExecuted).to.deep.equal([259 'X',260 'Y',261 'C',262 'Z'263 ]);264 });265 _mocha.it('should not call inherited _initialize methods on objects in a _doNotInitialize array', () => {266 const initializeExecuted = [],267 A = _make({268 _initialize () {269 initializeExecuted.push('A');270 }271 }),272 B = _make({273 _initialize () {274 initializeExecuted.push('B');275 }276 }),277 C = _make({278 _initialize () {279 initializeExecuted.push('C');280 }281 }),282 X = _make(_Initializable, [283 A284 ], {285 _doNotInitialize: [286 A287 ],288 _initialize () {289 initializeExecuted.push('X');290 }291 }),292 Y = _make(X, [293 B294 ], {295 _initialize () {296 initializeExecuted.push('Y');297 }298 }),299 Z = _make(Y, [300 C301 ], {302 _doNotInitialize: [303 B,304 C305 ],306 _initialize () {307 initializeExecuted.push('Z');308 }309 }),310 z = Z({311 initialize: false312 });313 z._doNotInitialize = [314 z315 ];316 z._initialize = () => {317 initializeExecuted.push('z');318 };319 z.initialize();320 _chai.expect(initializeExecuted).to.deep.equal([321 'X',322 'Y',323 'Z'324 ]);325 });326 _mocha.it('should not call inherited _initialize methods on objects in a _doNotInitialize set', () => {327 const initializeExecuted = [],328 A = _make({329 _initialize () {330 initializeExecuted.push('A');331 }332 }),333 B = _make({334 _initialize () {335 initializeExecuted.push('B');336 }337 }),338 C = _make({339 _initialize () {340 initializeExecuted.push('C');341 }342 }),343 X = _make(_Initializable, [344 A345 ], {346 _doNotInitialize: new Set([347 A348 ]),349 _initialize () {350 initializeExecuted.push('X');351 }352 }),353 Y = _make(X, [354 B355 ], {356 _initialize () {357 initializeExecuted.push('Y');358 }359 }),360 Z = _make(Y, [361 C362 ], {363 _doNotInitialize: new Set([364 B,365 C366 ]),367 _initialize () {368 initializeExecuted.push('Z');369 }370 }),371 z = Z({372 initialize: false373 });374 z._doNotInitialize = new Set([375 z376 ]);377 z._initialize = () => {378 initializeExecuted.push('z');379 };380 z.initialize();381 _chai.expect(initializeExecuted).to.deep.equal([382 'X',383 'Y',384 'Z'385 ]);386 });387 _mocha.it('should await async inherited _initialize methods', callbackFunction => {388 const initializeExecuted = [],389 A = _make({390 async _initialize () {391 await new Promise(resolve => {392 _later(34, resolve);393 });394 initializeExecuted.push('A');395 }396 }),397 B = _make({398 async _initialize () {399 await new Promise(resolve => {400 _later(21, resolve);401 });402 initializeExecuted.push('B');403 }404 }),405 C = _make({406 async _initialize () {407 await new Promise(resolve => {408 _later(13, resolve);409 });410 initializeExecuted.push('C');411 }412 }),413 X = _make(_Initializable, [414 A415 ], {416 _initialize () {417 initializeExecuted.push('X');418 }419 }),420 Y = _make(X, [421 B422 ], {423 _initialize () {424 initializeExecuted.push('Y');425 }426 }),427 Z = _make(Y, [428 C429 ], {430 _initialize () {431 initializeExecuted.push('Z');432 }433 }),434 z = Z({435 initialize: false436 });437 z._initialize = async () => {438 initializeExecuted.push('z');439 await new Promise(resolve => {440 _later(2, resolve);441 });442 };443 z.on('initializeComplete', () => {444 _chai.expect(initializeExecuted).to.deep.equal([445 'A',446 'X',447 'B',448 'Y',449 'C',450 'Z',451 'z'452 ]);453 callbackFunction();454 });455 z.initialize();456 });457 _mocha.it('should handle initialization errors', callbackFunction => {458 let capturedError,459 subscriptionExecuted = false;460 const CustomInitializable = _make(_Initializable, {461 _initialize () {462 throw _Error({463 name: 'CustomInitializationError'464 });465 }466 }),467 customInitializable = CustomInitializable(),468 domain = _domain.create();469 _chai.expect(customInitializable).to.have.property('initialized', false);470 customInitializable.on('initializeError', ({471 data: {472 error473 }474 }) => {475 _chai.expect(error).to.be.an.instanceOf(_Error);476 _chai.expect(error).to.have.property('name', 'CustomInitializationError');477 subscriptionExecuted = true;478 domain.enter();479 });480 domain.on('error', error => {481 capturedError = error;482 domain.exit();483 });484 _later(55, () => {485 _chai.expect(subscriptionExecuted).to.be.true;486 _chai.expect(capturedError).to.have.property('name', 'CustomInitializationError');487 callbackFunction();488 });489 });490 _mocha.it('should work with mixins', () => {491 const methodsExecuted = [],492 A = _make([493 _Initializable494 ], {495 _init (...args) {496 return Reflect.apply(_Initializable.prototype._init, this, args);497 },498 _initialize () {499 methodsExecuted.push('a');500 }501 }),502 B = _make([503 A504 ], {505 _init (...args) {506 return Reflect.apply(_Initializable.prototype._init, this, args);507 }508 }),509 C = _make([510 B511 ], {512 _init (...args) {513 return Reflect.apply(_Initializable.prototype._init, this, args);514 },515 _initialize () {516 methodsExecuted.push('c');517 }518 }),519 c = C();520 _chai.expect(c).not.to.be.an.instanceOf(_Initializable);521 _chai.expect(c).to.have.property('initialized', true);522 _chai.expect(methodsExecuted).to.deep.equal([523 'a',524 'c'525 ]);526 c.destroy();527 _chai.expect(c.initialized).to.be.undefined;528 });...
game.py
Source:game.py
...47 globalEventBus.subscribe(EventHeartBeat, sendReward)48 if inits :49 for pkg in inits :50 ftlog.info('init center logic of ->', pkg)51 exec 'from %s import _initialize; _initialize(1)' % (pkg)52 53 hallnewnotify._initialize()54 globalEventBus.subscribe(EventHeartBeat, hallnewnotify.onEventHeartBeat)55 from hall.entity import hallsportlottery56 hallsportlottery._initialize()57 globalEventBus.subscribe(EventHeartBeat, hallsportlottery.onEventHeartBeat)58 from hall.entity.usercoupon import user_coupon_details59 user_coupon_details._initialize()60 if serverType == gdata.SRV_TYPE_UTIL :61 from hall.servers.util.account_handler import updateOnLineInfos62 globalEventBus.subscribe(EventHeartBeat, updateOnLineInfos)63 #å
å¼åè°64 TGHall.getEventBus().subscribe(ChargeNotifyEvent, self._ChargeNotifyEvent)65 # å¨çº¿ä¿¡æ¯åå§å, ONLIEå¤çå¿
é¡»å¨UTILæå¡66 from hall.entity import hallonline67 hallonline._initialize()68 hallnewnotify._initialize()69 globalEventBus.subscribe(EventHeartBeat, hallnewnotify.onEventHeartBeat)70 if serverType == gdata.SRV_TYPE_TABLE or serverType == gdata.SRV_TYPE_ROOM :71 from hall.servers.room.room import reportRoomOnlineInfos72 globalEventBus.subscribe(EventHeartBeat, reportRoomOnlineInfos)73 from hall.entity import hallchatlog74 hallchatlog._initialize()75 # 注æ: å个模åé´æå
ååå§åç顺åº76 from hall.entity import hallitem, hallstore, hallvip, hallbenefits, \77 hallranking, hallshare, hallpromote, hallfree, hallgamelist, hallgamelist2, \78 halldailycheckin, hallmenulist, hallcoupon, hallmoduletip, \79 hallrename, hallads, hallflipcardluck, hallpopwnd, hallstartchip, \80 fivestarrate, match360kp, neituiguang, hallstocklimit, \81 hall_first_recharge, hallroulette, hallled, hall_exit_remind, hall_share2, \82 hall_yyb_gifts, hall_short_url, hall_red_packet_rain, hall_invite83 from hall.entity.hallactivity import activity84 from hall.entity.halltmpact import tmp_activity85 from hall.entity.hall_red_envelope import hall_red_envelope86 from hall.entity import hall_share387 # éå
·åå§å88 hallitem._initialize()89 # éè´åå§å90 hallstocklimit._initialize()91 # åååå§å92 hallstore._initialize()93 # VIPç³»ç»åå§å94 hallvip._initialize()95 # ææµéç³»ç»åå§å96 hallbenefits._initialize()97 # ç¨æ·åå§åºéåå§å98 hallstartchip._initialize()99 halldailycheckin._initialize()100 # æè¡æ¦101 hallranking._initialize(0)102 # æ´»å¨ç³»ç»åå§å103 activity._initialize()104 hallcoupon._initialize()105 hallshare._initialize()106 hallgamelist._initialize()107 hallgamelist2._initialize()108 hallmenulist._initialize()109 hallrename._initialize()110 hallmoduletip._initialize()111 hallads._initialize()112 hallflipcardluck._initialize()113 hallpopwnd._initialize()114 hallpromote._initialize()115 hallfree._initialize()116 fivestarrate._initialize()117 match360kp._initialize()118 neituiguang._initialize()119 from hall.entity import halltask120 halltask.initialize()121 # é»è®¤é
ç½®åå§å122 hallmoduledefault._initialize()123 halllocalnotification._initialize()124 #é¦å²ç¤¼å
é
ç½®125 hall_first_recharge._initialize()126 tmp_activity._initialize()127 #红å
模åé
ç½®åå§å128 hall_red_envelope._initialize()129 #é»ç³æ½å¥åå§å130 hallroulette._initialize()131 #ledé
ç½®åå§å132 hallled._initializeConfig()133 # éåºæé134 hall_exit_remind._initialize()135 # ä¸æ¹æ§å¶æ¨¡åå¼å
³136 hall_third_sdk_switch._initialize()137 # ååé
ç½®åå§å138 halldomains._initialize()139 # æ件å级模ååå§å140 hall_game_update._initialize()141 # ç»å½å¥å±æ¨¡ååå§å142 hall_login_reward._initialize()143 # éå
·è½¬æ¢æ¨¡ååå§å144 hall_item_exchange._initialize()145 # èªå»ºæ¡æ¿é´å·åå§å146 hall_friend_table._initialize()147 from hall.entity import hallalarm148 hallalarm.initialize()149 150 from hall.entity import hall_exmall151 hall_exmall._initialize()152 # æ¿å¡è´ä¹°æ示信æ¯æ¨¡ååå§å153 from hall.entity import hall_fangka_buy_info154 hall_fangka_buy_info._initialize()155 156 hall_short_url._initialize()157 hall_share2._initialize()158 hall_share3._initialize()159 hall_yyb_gifts._initialize()160 hall_red_packet_rain._initialize()161 from hall.entity import hall1yuanduobao162 hall1yuanduobao._initialize()163 164 hall_invite._initialize()165 hall_statics._initialize()166 hall_joinfriendgame._initialize()167 hall_jiguang_jpush._initialize()168 hall_robot_user._initialize()169 # 红å
ä»»å¡åå§å170 from hall.entity import hall_red_packet_task, hall_red_packet_exchange, hall_red_packet_main171 hall_red_packet_task._initialize()172 hall_red_packet_exchange._initialize()173 hall_red_packet_main._initialize()174 175 # å¿«éå¼å§æ¨è模ååå§å176 from hall.entity import hall_quick_start_recommend177 hall_quick_start_recommend._initialize()178 179 # æ件éåºæ½ç模ååå§å180 from hall.entity import hall_exit_plugin_remind181 hall_exit_plugin_remind._initialize()182 183 # ç»å½ç´æ¥è¿å
¥æ¸¸æ模ååå§å184 from hall.entity import hall_enter_game_after_login185 hall_enter_game_after_login._initialize()186 187 # ç®åé请åè½åå§å188 from hall.entity import hall_simple_invite189 hall_simple_invite.initialize()190 def initGameAfter(self):191 from hall.entity.hallactivity import activity192 activity.initAfter()193 def getInitDataKeys(self):194 '''195 åå¾æ¸¸ææ°æ®åå§åçå段å表196 '''197 return self._account.getInitDataKeys()198 def getInitDataValues(self):199 '''...
view-filters.spec.js
Source:view-filters.spec.js
...4 function _currentHref() {5 return setLocationHrefSpy.args[setLocationHrefSpy.args.length-1][0];6 }7 beforeEach(function() {8 filters._initialize('');9 setLocationHrefSpy = sinon.spy();10 filters._setLocationHref = setLocationHrefSpy;11 });12 describe('#initialization', function() {13 it('should clear the filters on subsequent calls', function() {14 filters._initialize('?filters=country:Brazil');15 assert.deepEqual(['Brazil'], filters.get('country'));16 filters._initialize('');17 assert.equal(undefined, filters.get('country'));18 });19 it('should work with multiple filters', function() {20 var expectedFilters = {21 country: ['Brazil'],22 state: ['Paraiba']23 };24 filters._initialize('?filters=country:Brazil|state:Paraiba');25 assert.deepEqual(expectedFilters, filters.get());26 });27 it('should work with multiple values for the same filter', function() {28 var expectedFilters = {29 country: ['Brazil', 'Argentina'],30 state: ['Paraiba']31 };32 filters._initialize('?filters=country:Brazil|state:Paraiba|country:Argentina');33 assert.deepEqual(expectedFilters, filters.get());34 });35 it('should keep the order defined in the query string', function() {36 var expectedFiltersSorted = {37 country: ['Argentina', 'Brazil']38 },39 expectedFiltersReverse = {40 country: ['Brazil', 'Argentina']41 };42 filters._initialize('?filters=country:Argentina|country:Brazil');43 assert.deepEqual(expectedFiltersSorted, filters.get());44 filters._initialize('?filters=country:Brazil|country:Argentina');45 assert.deepEqual(expectedFiltersReverse, filters.get());46 });47 it('should work with a single numeric filter', function() {48 var expectedFilters = {49 year: ['2014']50 };51 filters._initialize('?filters=year:2014');52 assert.deepEqual(expectedFilters, filters.get());53 });54 it('should work with quoted filters', function() {55 var expectedFilters = {56 country: ['"Brazil"']57 };58 filters._initialize('?filters=country:"Brazil"');59 assert.deepEqual(expectedFilters, filters.get());60 });61 it('should work with filters with colons', function() {62 var expectedFilters = {63 time: ['11:00', '']64 };65 filters._initialize('?filters=time:11:00|time:');66 assert.deepEqual(expectedFilters, filters.get());67 });68 });69 describe('#get', function(){70 it('should return all filters if called without params', function(){71 var expectedFilters = {72 country: ['Brazil']73 };74 filters._initialize('?filters=country:Brazil');75 assert.deepEqual(expectedFilters, filters.get());76 });77 it('should return the requested filter field', function(){78 var countryFilter;79 filters._initialize('?filters=country:Brazil');80 countryFilter = filters.get('country');81 assert.equal(1, countryFilter.length);82 assert.equal('Brazil', countryFilter[0]);83 });84 it('should return an empty object if there\'re no filters', function(){85 filters._initialize('');86 assert.deepEqual({}, filters.get());87 });88 it('should return undefined if there\'s no filter with the requested field', function(){89 var cityFilter;90 filters._initialize('?filters=country:Brazil');91 cityFilter = filters.get('city');92 assert.equal(undefined, cityFilter);93 });94 });95 describe('#set', function(){96 it('should set the filters', function(){97 var expectedFilters = {98 country: 'Brazil'99 };100 filters.set('country', 'Brazil');101 assert.deepEqual(expectedFilters, filters.get());102 });103 it('should update the url', function(){104 var expectedSearch = '?filters=country%3ABrazil%7Ccountry%3AArgentina' +...
test-wasi-initialize-validation.js
Source:test-wasi-initialize-validation.js
...32 }33 );34 }35 {36 // Verify that a _initialize() export was passed.37 const wasi = new WASI({});38 const wasm = await WebAssembly.compile(bufferSource);39 const instance = await WebAssembly.instantiate(wasm);40 Object.defineProperty(instance, 'exports', {41 get() {42 return { _initialize: 5, memory: new Uint8Array() };43 },44 });45 assert.throws(46 () => { wasi.initialize(instance); },47 {48 code: 'ERR_INVALID_ARG_TYPE',49 message: /"instance\.exports\._initialize" property must be of type function/50 }51 );52 }53 {54 // Verify that a _start export was not passed.55 const wasi = new WASI({});56 const wasm = await WebAssembly.compile(bufferSource);57 const instance = await WebAssembly.instantiate(wasm);58 Object.defineProperty(instance, 'exports', {59 get() {60 return {61 _start() {},62 _initialize() {},63 memory: new Uint8Array(),64 };65 }66 });67 assert.throws(68 () => { wasi.initialize(instance); },69 {70 code: 'ERR_INVALID_ARG_TYPE',71 message: /"instance\.exports\._start" property must be undefined/72 }73 );74 }75 {76 // Verify that a memory export was passed.77 const wasi = new WASI({});78 const wasm = await WebAssembly.compile(bufferSource);79 const instance = await WebAssembly.instantiate(wasm);80 Object.defineProperty(instance, 'exports', {81 get() { return { _initialize() {} }; }82 });83 assert.throws(84 () => { wasi.initialize(instance); },85 {86 code: 'ERR_INVALID_ARG_TYPE',87 message: /"instance\.exports\.memory" property must be of type object/88 }89 );90 }91 {92 // Verify that a non-ArrayBuffer memory.buffer is rejected.93 const wasi = new WASI({});94 const wasm = await WebAssembly.compile(bufferSource);95 const instance = await WebAssembly.instantiate(wasm);96 Object.defineProperty(instance, 'exports', {97 get() {98 return {99 _initialize() {},100 memory: {},101 };102 }103 });104 // The error message is a little white lie because any object105 // with a .buffer property of type ArrayBuffer is accepted,106 // but 99% of the time a WebAssembly.Memory object is used.107 assert.throws(108 () => { wasi.initialize(instance); },109 {110 code: 'ERR_INVALID_ARG_TYPE',111 message: /"instance\.exports\.memory\.buffer" property must be an WebAssembly\.Memory/112 }113 );114 }115 {116 // Verify that an argument that duck-types as a WebAssembly.Instance117 // is accepted.118 const wasi = new WASI({});119 const wasm = await WebAssembly.compile(bufferSource);120 const instance = await WebAssembly.instantiate(wasm);121 Object.defineProperty(instance, 'exports', {122 get() {123 return {124 _initialize() {},125 memory: { buffer: new ArrayBuffer(0) },126 };127 }128 });129 wasi.initialize(instance);130 }131 {132 // Verify that a WebAssembly.Instance from another VM context is accepted.133 const wasi = new WASI({});134 const instance = await vm.runInNewContext(`135 (async () => {136 const wasm = await WebAssembly.compile(bufferSource);137 const instance = await WebAssembly.instantiate(wasm);138 Object.defineProperty(instance, 'exports', {139 get() {140 return {141 _initialize() {},142 memory: new WebAssembly.Memory({ initial: 1 })143 };144 }145 });146 return instance;147 })()148 `, { bufferSource });149 wasi.initialize(instance);150 }151 {152 // Verify that initialize() can only be called once.153 const wasi = new WASI({});154 const wasm = await WebAssembly.compile(bufferSource);155 const instance = await WebAssembly.instantiate(wasm);156 Object.defineProperty(instance, 'exports', {157 get() {158 return {159 _initialize() {},160 memory: new WebAssembly.Memory({ initial: 1 })161 };162 }163 });164 wasi.initialize(instance);165 assert.throws(166 () => { wasi.initialize(instance); },167 {168 code: 'ERR_WASI_ALREADY_STARTED',169 message: /^WASI instance has already started$/170 }171 );172 }173})().then(common.mustCall());
wasi.js
Source:wasi.js
...127 throw new ERR_INVALID_ARG_TYPE(128 'instance.exports._start', 'undefined', _initialize);129 }130 if (_initialize !== undefined) {131 _initialize();132 }133 }134}135module.exports = { WASI };136function wasiReturnOnProcExit(rval) {137 // If __wasi_proc_exit() does not terminate the process, an assertion is138 // triggered in the wasm runtime. Node can sidestep the assertion and return139 // an exit code by recording the exit code, and throwing a JavaScript140 // exception that WebAssembly cannot catch.141 this[kExitCode] = rval;142 throw kExitCode;...
wijmo.vue2.input.js
Source:wijmo.vue2.input.js
...20exports.Vue = vue_1.default || VueModule;21exports.WjComboBox = exports.Vue.component('wj-combo-box', {22template: '<div/>', props: wjcVue2Base._getProps('wijmo.input.ComboBox'), mounted: function()23{24wjcVue2Base._initialize(this, new wjcInput.ComboBox(this.$el))25}26});27exports.WjAutoComplete = exports.Vue.component('wj-auto-complete', {28template: '<div/>', props: wjcVue2Base._getProps('wijmo.input.AutoComplete'), mounted: function()29{30wjcVue2Base._initialize(this, new wjcInput.AutoComplete(this.$el))31}32});33exports.WjCalendar = exports.Vue.component('wj-calendar', {34template: '<div/>', props: wjcVue2Base._getProps('wijmo.input.Calendar'), mounted: function()35{36wjcVue2Base._initialize(this, new wjcInput.Calendar(this.$el))37}38});39exports.WjColorPicker = exports.Vue.component('wj-color-picker', {40template: '<div/>', props: wjcVue2Base._getProps('wijmo.input.ColorPicker'), mounted: function()41{42wjcVue2Base._initialize(this, new wjcInput.ColorPicker(this.$el))43}44});45exports.WjInputMask = exports.Vue.component('wj-input-mask', {46template: '<div/>', props: wjcVue2Base._getProps('wijmo.input.InputMask'), mounted: function()47{48wjcVue2Base._initialize(this, new wjcInput.InputMask(this.$el))49}50});51exports.WjInputColor = exports.Vue.component('wj-input-color', {52template: '<div/>', props: wjcVue2Base._getProps('wijmo.input.InputColor'), mounted: function()53{54wjcVue2Base._initialize(this, new wjcInput.InputColor(this.$el))55}56});57exports.WjMultiSelect = exports.Vue.component('wj-multi-select', {58template: '<div/>', props: wjcVue2Base._getProps('wijmo.input.MultiSelect'), mounted: function()59{60wjcVue2Base._initialize(this, new wjcInput.MultiSelect(this.$el))61}62});63exports.WjMultiAutoComplete = exports.Vue.component('wj-multi-auto-complete', {64template: '<div/>', props: wjcVue2Base._getProps('wijmo.input.MultiAutoComplete'), mounted: function()65{66wjcVue2Base._initialize(this, new wjcInput.MultiAutoComplete(this.$el))67}68});69exports.WjInputNumber = exports.Vue.component('wj-input-number', {70template: '<div/>', props: wjcVue2Base._getProps('wijmo.input.InputNumber'), mounted: function()71{72wjcVue2Base._initialize(this, new wjcInput.InputNumber(this.$el))73}74});75exports.WjInputDate = exports.Vue.component('wj-input-date', {76template: '<div/>', props: wjcVue2Base._getProps('wijmo.input.InputDate'), mounted: function()77{78wjcVue2Base._initialize(this, new wjcInput.InputDate(this.$el))79}80});81exports.WjInputTime = exports.Vue.component('wj-input-time', {82template: '<div/>', props: wjcVue2Base._getProps('wijmo.input.InputTime'), mounted: function()83{84wjcVue2Base._initialize(this, new wjcInput.InputTime(this.$el))85}86});87exports.WjInputDateTime = exports.Vue.component('wj-input-date-time', {88template: '<div/>', props: wjcVue2Base._getProps('wijmo.input.InputDateTime'), mounted: function()89{90wjcVue2Base._initialize(this, new wjcInput.InputDateTime(this.$el))91}92});93exports.WjListBox = exports.Vue.component('wj-list-box', {94template: '<div/>', props: wjcVue2Base._getProps('wijmo.input.ListBox'), mounted: function()95{96wjcVue2Base._initialize(this, new wjcInput.ListBox(this.$el))97}98});99exports.WjMenu = exports.Vue.component('wj-menu', {100template: '<div/>', props: wjcVue2Base._getProps('wijmo.input.Menu'), mounted: function()101{102wjcVue2Base._initialize(this, new wjcInput.Menu(this.$el))103}104});105exports.WjPopup = exports.Vue.component('wj-popup', {106template: '<div><slot/></div>', props: wjcVue2Base._getProps('wijmo.input.Popup'), mounted: function()107{108wjcVue2Base._initialize(this, new wjcInput.Popup(this.$el))109}110})...
_core.py
Source:_core.py
...41 return _jpype.isStarted()4243def startJVM(jvm, *args) :44 _jpype.startup(jvm, tuple(args), True)45 _jclass._initialize()46 _jarray._initialize()47 _jwrapper._initialize()48 _jproxy._initialize()49 _jexception._initialize()50 _jcollection._initialize()51 _jobject._initialize()52 _properties._initialize()53 nio._initialize()54 reflect._initialize()55 56 # start the reference deamon thread 57 if _usePythonThreadForDaemon :58 _refdaemon.startPython()59 else:60 _refdaemon.startJava()61 62def attachToJVM(jvm) :63 _jpype.attach(jvm)64 65 _jclass._initialize()66 _jarray._initialize()67 _jwrapper._initialize()68 _jproxy._initialize()69 _jexception._initialize()70 _jcollection._initialize()71 _jobject._initialize()72 _properties._initialize()73 74def shutdownJVM() :75 _refdaemon.stop()76 _jpype.shutdown()77 78def isThreadAttachedToJVM() :79 return _jpype.isThreadAttachedToJVM()80 81def attachThreadToJVM() :82 _jpype.attachThreadToJVM()83 84def detachThreadFromJVM() : 85 _jpype.detachThreadFromJVM()86
...
class.js
Source:class.js
...22 return fn.apply( this, args );23 }24 var getInstance = function(){25 var args = Array.prototype.slice.call( arguments, 0 );26 _instances[ _unique++ ] = new _initialize( args );27 return _instances[ _unique - 1 ];28 }29 var empty = function(){30 for ( var i = 0, c; c = _instances[i++]; ){31 c = null;32 }33 _instances = [];34 _instances.length = 0;35 _unique = 0;36 }37 var getCount = function(){38 return _unique;39 }40 var getPrototype = function(){...
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const context = await browser.newContext();5 const page = await context.newPage();6 const internalPage = page._page;7 const pageObject = internalPage._delegate;8 const internalPage2 = pageObject._page;9 const pageObject2 = internalPage2._delegate;10 const internalPage3 = pageObject2._page;11 await page.screenshot({ path: 'google.png' });12 await browser.close();13})();14const { chromium } = require('playwright');15(async () => {16 const browser = await chromium.launch({ headless: false });17 const context = await browser.newContext();18 const page = await context.newPage();19 const internalPage = page._page;20 const pageObject = internalPage._delegate;21 const internalPage2 = pageObject._page;22 const pageObject2 = internalPage2._delegate;23 const internalPage3 = pageObject2._page;24 await page.screenshot({ path: 'google.png' });25 await browser.close();26})();
Using AI Code Generation
1const playwright = require('playwright');2(async () => {3 for (const browserType of BROWSER) {4 const browser = await playwright[browserType].launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: `example-${browserType}.png` });8 await browser.close();9 }10})();11const playwright = require('playwright');12(async () => {13 const browserServer = await playwright.webkit._launchServer({ headless: false });14 const webSocketDebuggerUrl = await response.json();15 const browser = await playwright.webkit.connect({ wsEndpoint: webSocketDebuggerUrl.webSocketDebuggerUrl });16 const context = await browser.newContext();17 const page = await context.newPage();18 await page.screenshot({ path: `example.png` });19 await browser.close();20 await browserServer.close();21})();22const playwright = require('playwright');23(async () => {24 const browser = await playwright.webkit._launchPersistentContext('/tmp/tempdir', { headless: false });25 const context = await browser.newContext();26 const page = await context.newPage();27 await page.screenshot({ path: `example.png` });28 await browser.close();29})();30const playwright = require('playwright');31(async () => {32 const browserServer = await playwright.webkit._launchPersistentServer('/tmp/tempdir', { headless: false });33 const webSocketDebuggerUrl = await response.json();
Using AI Code Generation
1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({ path: 'google.png' });7 await browser.close();8})();9![Screenshot](google.png)
Using AI Code Generation
1const { _initialize } = require('playwright/lib/server/chromium/crBrowser');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const result = await _initialize(page);8 console.log(result);9 await browser.close();10})();11[MIT](LICENSE)
Using AI Code Generation
1const path = require('path');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch({ headless: false });5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.click('input[name="q"]');8 await page.fill('input[name="q"]', 'Playwright');9 await page.press('input[name="q"]', 'Enter');10 await page.close();11 await context.close();12 await browser.close();13})();
Using AI Code Generation
1const { _initialize } = require('playwright/lib/server/playwright');2const { chromium } = _initialize();3(async () => {4 const browser = await chromium.launch({ headless: false });5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: `example.png` });8 await browser.close();9})();10[Apache 2.0](LICENSE)
Using AI Code Generation
1const { Playwright } = require('@playwright/test');2const { PlaywrightInternal } = Playwright;3const { _initialize } = PlaywrightInternal.prototype;4PlaywrightInternal.prototype._initialize = async function (options) {5 await _initialize.call(this, options);6 options.params = { ...options.params, 'foo': 'bar' };7};8const { test } = require('@playwright/test');9test('test', async ({ page }) => {10});11[Apache 2.0](LICENSE)
Using AI Code Generation
1import { _initialize } from 'playwright/lib/server/playwright';2const playwright = _initialize();3const browser = await playwright.chromium.launch();4const page = await browser.newPage();5await page.screenshot({ path: 'example.png' });6await browser.close();
Using AI Code Generation
1const { _initialize } = require('playwright/lib/server/playwright.js');2const { chromium, webkit, firefox } = require('playwright');3(async () => {4 const playwright = await _initialize();5 const browser = await chromium.launch();6 const page = await browser.newPage();7 await browser.close();8})();9const { _launchServer } = require('playwright/lib/server/playwright.js');10const { chromium, webkit, firefox } = require('playwright');11(async () => {12 const server = await _launchServer();13 const browser = await chromium.connect({14 wsEndpoint: server.wsEndpoint(),15 });16 const page = await browser.newPage();17 await browser.close();18 await server.close();19})();20const { _launchServer } = require('playwright/lib/server/playwright.js');21const { chromium, webkit, firefox } = require('playwright');22(async () => {23 const server = await _launchServer();24 const browser = await chromium.connect({25 wsEndpoint: server.wsEndpoint(),26 });27 const page = await browser.newPage();28 await browser.close();29 await server.close();30})();31const { _launchServer } = require('playwright/lib/server/playwright.js');32const { chromium, webkit, firefox } = require('playwright');33(async () => {34 const server = await _launchServer();35 const browser = await chromium.connect({36 wsEndpoint: server.wsEndpoint(),37 });38 const page = await browser.newPage();39 await browser.close();40 await server.close();41})();42const { _launchServer } = require('playwright/lib/server/playwright.js');43const { chromium, webkit, firefox } = require('playwright');44(async () => {45 const server = await _launchServer();46 const browser = await chromium.connect({47 wsEndpoint: server.wsEndpoint(),48 });49 const page = await browser.newPage();
Using AI Code Generation
1const { PlaywrightInternal } = require('playwright');2const page = PlaywrightInternal._initialize(new Page());3const browser = PlaywrightInternal._initialize(new Browser());4const context = PlaywrightInternal._initialize(new BrowserContext());5const frame = PlaywrightInternal._initialize(new Frame());6const elementHandle = PlaywrightInternal._initialize(new ElementHandle());7const jsHandle = PlaywrightInternal._initialize(new JSHandle());8const request = PlaywrightInternal._initialize(new Request());9const response = PlaywrightInternal._initialize(new Response());10const route = PlaywrightInternal._initialize(new Route());
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!