How to use _initialize method in Puppeteer

Best JavaScript code snippet using puppeteer

initializable.js

Source:initializable.js Github

copy

Full Screen

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 });...

Full Screen

Full Screen

game.py

Source:game.py Github

copy

Full Screen

...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 '''...

Full Screen

Full Screen

view-filters.spec.js

Source:view-filters.spec.js Github

copy

Full Screen

...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' +...

Full Screen

Full Screen

test-wasi-initialize-validation.js

Source:test-wasi-initialize-validation.js Github

copy

Full Screen

...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());

Full Screen

Full Screen

wasi.js

Source:wasi.js Github

copy

Full Screen

...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;...

Full Screen

Full Screen

wijmo.vue2.input.js

Source:wijmo.vue2.input.js Github

copy

Full Screen

...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})...

Full Screen

Full Screen

_core.py

Source:_core.py Github

copy

Full Screen

...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 ...

Full Screen

Full Screen

class.js

Source:class.js Github

copy

Full Screen

...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(){...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless: false, args: ['--no-sandbox', '--disable-setuid-sandbox']});4 const page = await browser.newPage();5 await page.screenshot({path: 'example.png'});6 await browser.close();7})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const browser = await puppeteer.launch({headless: false});3const page = await browser.newPage();4await page.screenshot({path: 'example.png'});5await browser.close();6const Nightmare = require('nightmare');7const nightmare = Nightmare({ show: true });8 .type('input[title="Search"]', 'github nightmare')9 .click('input[value="Google Search"]')10 .wait('#resultStats')11 .evaluate(() => document.querySelector('#resultStats').innerHTML)12 .end()13 .then(console.log)14 .catch(error => {15 console.error('Search failed:', error)16 });17const webdriver = require('selenium-webdriver');18const driver = new webdriver.Builder()19 .forBrowser('firefox')20 .build();21driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');22driver.findElement(webdriver.By.name('btnG')).click();23driver.wait(function() {24 return driver.getTitle().then(function(title) {25 return title === 'webdriver - Google Search';26 });27}, 1000);28driver.quit();29var casper = require('casper').create();30 this.fill('form[action="/search"]', { q: 'casperjs' }, true);31});32casper.then(function() {33 this.capture('google.png');34});35casper.run();36var webdriver = require('selenium-webdriver');37var driver = new webdriver.Builder().forBrowser('chrome').build();38var element = driver.findElement(webdriver.By.name('q'));39element.sendKeys('webdriver');40element.submit();41driver.wait(function() {42 return driver.getTitle().then(function(title) {43 return title === 'webdriver - Google Search';44 });45}, 1000);46driver.quit();47const { chromium } = require('playwright');48(async () => {49 const browser = await chromium.launch({ headless: false });50 const context = await browser.newContext();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless:false});4 const page = await browser.newPage();5 await page.pdf({path: 'google.pdf', format: 'A4'});6 await browser.close();7})();8const puppeteer = require('puppeteer');9(async () => {10 const browser = await puppeteer.launch({headless:false});11 const page = await browser.newPage();12 await page.pdf({path: 'google.pdf', format: 'A4'});13 await browser.close();14})();15const puppeteer = require('puppeteer');16(async () => {17 const browser = await puppeteer.launch({headless:false});18 const page = await browser.newPage();19 await page.pdf({path: 'google.pdf', format: 'A4'});20 await browser.close();21})();22const puppeteer = require('puppeteer');23(async () => {24 const browser = await puppeteer.launch({headless:false});25 const page = await browser.newPage();26 await page.pdf({path: 'google.pdf', format: 'A4'});27 await browser.close();28})();29const puppeteer = require('puppeteer');30(async () => {31 const browser = await puppeteer.launch({headless:false});32 const page = await browser.newPage();33 await page.pdf({path: 'google.pdf', format: 'A4'});34 await browser.close();35})();36const puppeteer = require('puppeteer');37(async () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const browser = await puppeteer.launch({3});4const puppeteer = require('puppeteer');5const browser = await puppeteer.launch({6});7const puppeteer = require('puppeteer');8const browser = await puppeteer.launch({9});10const puppeteer = require('puppeteer');11const browser = await puppeteer.launch({12});13const puppeteer = require('puppeteer');14const browser = await puppeteer.launch({15});16const puppeteer = require('puppeteer');17const browser = await puppeteer.launch({

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const config = require('./config.json');3const browser = await puppeteer.launch(config.launch);4const page = await browser.newPage();5await page._initialize(config.initialize);6await page.screenshot({path: 'google.png'});7await browser.close();8{9 "launch": {10 },11 "initialize": {12 "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"13 }14}15{16 "scripts": {17 },18 "dependencies": {19 }20}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { PuppeteerPage } from 'puppeteer-page-decorators';2import { _initialize } from 'puppeteer-page-decorators';3export class TestPage extends PuppeteerPage {4 constructor(page) {5 super(page);6 }7}8const page = await browser.newPage();9const testPage = new TestPage(page);10_initialize(testPage);11testPage.click('selector');12testPage.waitFor('selector');13import { TestPage } from './test';14describe('Test', () => {15 it('should work', async () => {16 const page = await browser.newPage();17 const testPage = new TestPage(page);18 await testPage.click('selector');19 await testPage.waitFor('selector');20 });21});22import { TestPage } from './test';23describe('Test', () => {24 it('should work', async () => {25 const page = await browser.newPage();26 const testPage = new TestPage(page);27 await testPage.click('selector');28 await testPage.waitFor('selector');29 });30});31import { TestPage } from './test';32describe('Test', () => {33 it('should work', async () => {34 const page = await browser.newPage();35 const testPage = new TestPage(page);36 await testPage.click('selector');37 await testPage.waitFor('selector');38 });39});40import { TestPage } from './test';41describe('Test', () => {42 it('should work', async () => {43 const page = await browser.newPage();44 const testPage = new TestPage(page);45 await testPage.click('selector');

Full Screen

Using AI Code Generation

copy

Full Screen

1const Apify = require('apify');2Apify.main(async () => {3 const requestList = new Apify.RequestList({4 });5 await requestList.initialize();6 const crawler = new Apify.PuppeteerCrawler({7 handlePageFunction: async ({ page, request }) => {8 console.log('Page opened.', page.url());9 },10 handleFailedRequestFunction: async ({ request }) => {11 console.log('Request failed too many times', request.url);12 },13 });14 await crawler.run();15});16await Apify.call('test');17const output = await Apify.getValue('OUTPUT');18console.log(output);19await Apify.call('test');20const output = await Apify.getValue('OUTPUT');21console.log(output);22const Apify = require('apify');23Apify.main(async () => {24 const requestList = new Apify.RequestList({25 });26 await requestList.initialize();27 const crawler = new Apify.PuppeteerCrawler({28 handlePageFunction: async ({ page, request }) => {29 console.log('Page opened.', page.url());30 },31 handleFailedRequestFunction: async ({ request }) => {32 console.log('Request failed too many times', request.url);33 },34 _initialize: async () => {35 const browser = await Apify.launchPuppeteer();36 const page = await browser.newPage();37 return { browser, page };38 },39 });

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 Puppeteer 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