Best JavaScript code snippet using playwright-internal
UrlTemplateImageryProviderSpec.js
Source:UrlTemplateImageryProviderSpec.js
...96 expect(provider.tilingScheme).toBeInstanceOf(WebMercatorTilingScheme);97 expect(provider.rectangle).toEqual(new WebMercatorTilingScheme().rectangle);98 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {99 // Just return any old image.100 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);101 });102 return provider.requestImage(0, 0, 0).then(function(image) {103 expect(Resource._Implementations.createImage).toHaveBeenCalled();104 expect(image).toBeInstanceOf(Image);105 });106 });107 });108 it('when no credit is supplied, the provider has no logo', function() {109 var provider = new UrlTemplateImageryProvider({110 url: 'made/up/tms/server'111 });112 expect(provider.credit).toBeUndefined();113 });114 it('turns the supplied credit into a logo', function() {115 var providerWithCredit = new UrlTemplateImageryProvider({116 url: 'made/up/gms/server',117 credit: 'Thanks to our awesome made up source of this imagery!'118 });119 expect(providerWithCredit.credit).toBeDefined();120 });121 it('rectangle passed to constructor does not affect tile numbering', function() {122 var rectangle = new Rectangle(0.1, 0.2, 0.3, 0.4);123 var provider = new UrlTemplateImageryProvider({124 url: 'made/up/tms/server/{z}/{x}/{reverseY}',125 rectangle: rectangle126 });127 return pollToPromise(function() {128 return provider.ready;129 }).then(function() {130 expect(provider.tileWidth).toEqual(256);131 expect(provider.tileHeight).toEqual(256);132 expect(provider.maximumLevel).toBeUndefined();133 expect(provider.minimumLevel).toBe(0);134 expect(provider.tilingScheme).toBeInstanceOf(WebMercatorTilingScheme);135 expect(provider.rectangle).toEqualEpsilon(rectangle, CesiumMath.EPSILON14);136 expect(provider.tileDiscardPolicy).toBeUndefined();137 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {138 expect(url).toContain('/0/0/0');139 // Just return any old image.140 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);141 });142 return provider.requestImage(0, 0, 0).then(function(image) {143 expect(Resource._Implementations.createImage).toHaveBeenCalled();144 expect(image).toBeInstanceOf(Image);145 });146 });147 });148 it('uses minimumLevel and maximumLevel passed to constructor', function() {149 var provider = new UrlTemplateImageryProvider({150 url: 'made/up/tms/server',151 minimumLevel: 1,152 maximumLevel: 5153 });154 return pollToPromise(function() {155 return provider.ready;156 }).then(function() {157 expect(provider.minimumLevel).toEqual(1);158 expect(provider.maximumLevel).toEqual(5);159 });160 });161 it('raises error event when image cannot be loaded', function() {162 var provider = new UrlTemplateImageryProvider({163 url: 'made/up/tms/server'164 });165 var layer = new ImageryLayer(provider);166 var tries = 0;167 provider.errorEvent.addEventListener(function(error) {168 expect(error.timesRetried).toEqual(tries);169 ++tries;170 if (tries < 3) {171 error.retry = true;172 }173 setTimeout(function() {174 RequestScheduler.update();175 }, 1);176 });177 Resource._Implementations.createImage = function(url, crossOrigin, deferred) {178 if (tries === 2) {179 // Succeed after 2 tries180 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);181 } else {182 // fail183 setTimeout(function() {184 deferred.reject();185 }, 1);186 }187 };188 return pollToPromise(function() {189 return provider.ready;190 }).then(function() {191 var imagery = new Imagery(layer, 0, 0, 0);192 imagery.addReference();193 layer._requestImagery(imagery);194 RequestScheduler.update();195 return pollToPromise(function() {196 return imagery.state === ImageryState.RECEIVED;197 }).then(function() {198 expect(imagery.image).toBeInstanceOf(Image);199 expect(tries).toEqual(2);200 imagery.releaseReference();201 });202 });203 });204 it('evaluation of pattern X Y reverseX reverseY Z reverseZ', function() {205 var provider = new UrlTemplateImageryProvider({206 url: 'made/up/tms/server/{z}/{reverseZ}/{reverseY}/{y}/{reverseX}/{x}.PNG',207 tilingScheme: new GeographicTilingScheme(),208 maximumLevel: 6209 });210 return pollToPromise(function() {211 return provider.ready;212 }).then(function() {213 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {214 expect(url).toEqual('made/up/tms/server/2/3/2/1/4/3.PNG');215 // Just return any old image.216 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);217 });218 return provider.requestImage(3, 1, 2).then(function(image) {219 expect(Resource._Implementations.createImage).toHaveBeenCalled();220 expect(image).toBeInstanceOf(Image);221 });222 });223 });224 it('evaluation of schema zero padding for X Y Z as 0000', function() {225 var provider = new UrlTemplateImageryProvider({226 url: 'made/up/tms/server/{z}/{reverseZ}/{reverseY}/{y}/{reverseX}/{x}.PNG',227 urlSchemeZeroPadding: {228 '{x}' : '0000',229 '{y}' : '0000',230 '{z}' : '0000'231 },232 tilingScheme: new GeographicTilingScheme(),233 maximumLevel: 6234 });235 return pollToPromise(function() {236 return provider.ready;237 }).then(function() {238 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {239 expect(url).toEqual('made/up/tms/server/0002/3/2/0001/4/0003.PNG');240 // Just return any old image.241 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);242 });243 return provider.requestImage(3, 1, 2).then(function(image) {244 expect(Resource._Implementations.createImage).toHaveBeenCalled();245 expect(image).toBeInstanceOf(Image);246 });247 });248 });249 it('evaluation of schema zero padding for reverseX reverseY reverseZ as 0000', function() {250 var provider = new UrlTemplateImageryProvider({251 url: 'made/up/tms/server/{z}/{reverseZ}/{reverseY}/{y}/{reverseX}/{x}.PNG',252 urlSchemeZeroPadding: {253 '{reverseX}' : '0000',254 '{reverseY}' : '0000',255 '{reverseZ}' : '0000'256 },257 tilingScheme: new GeographicTilingScheme(),258 maximumLevel: 6259 });260 return pollToPromise(function() {261 return provider.ready;262 }).then(function() {263 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {264 expect(url).toEqual('made/up/tms/server/2/0003/0002/1/0004/3.PNG');265 // Just return any old image.266 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);267 });268 return provider.requestImage(3, 1, 2).then(function(image) {269 expect(Resource._Implementations.createImage).toHaveBeenCalled();270 expect(image).toBeInstanceOf(Image);271 });272 });273 });274 it('evaluation of schema zero padding for x y z as 0000 and large x and y', function() {275 var provider = new UrlTemplateImageryProvider({276 url: 'made/up/tms/server/{z}/{reverseZ}/{reverseY}/{y}/{reverseX}/{x}.PNG',277 urlSchemeZeroPadding: {278 '{x}' : '0000',279 '{y}' : '0000',280 '{z}' : '0000'281 },282 tilingScheme: new GeographicTilingScheme(),283 maximumLevel: 6284 });285 return pollToPromise(function() {286 return provider.ready;287 }).then(function() {288 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {289 expect(url).toEqual('made/up/tms/server/0005/0/21/0010/51/0012.PNG');290 // Just return any old image.291 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);292 });293 return provider.requestImage(12, 10, 5).then(function(image) {294 expect(Resource._Implementations.createImage).toHaveBeenCalled();295 expect(image).toBeInstanceOf(Image);296 });297 });298 });299 it('evaluates pattern northDegrees', function() {300 var provider = new UrlTemplateImageryProvider({301 url: '{northDegrees}',302 tilingScheme: new GeographicTilingScheme()303 });304 return pollToPromise(function() {305 return provider.ready;306 }).then(function() {307 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {308 expect(url).toEqualEpsilon(45.0, CesiumMath.EPSILON11);309 // Just return any old image.310 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);311 });312 return provider.requestImage(3, 1, 2).then(function(image) {313 expect(Resource._Implementations.createImage).toHaveBeenCalled();314 expect(image).toBeInstanceOf(Image);315 });316 });317 });318 it('evaluates pattern southDegrees', function() {319 var provider = new UrlTemplateImageryProvider({320 url: '{southDegrees}',321 tilingScheme: new GeographicTilingScheme()322 });323 return pollToPromise(function() {324 return provider.ready;325 }).then(function() {326 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {327 expect(url).toEqualEpsilon(0.0, CesiumMath.EPSILON11);328 // Just return any old image.329 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);330 });331 return provider.requestImage(3, 1, 2).then(function(image) {332 expect(Resource._Implementations.createImage).toHaveBeenCalled();333 expect(image).toBeInstanceOf(Image);334 });335 });336 });337 it('evaluates pattern eastDegrees', function() {338 var provider = new UrlTemplateImageryProvider({339 url: '{eastDegrees}',340 tilingScheme: new GeographicTilingScheme()341 });342 return pollToPromise(function() {343 return provider.ready;344 }).then(function() {345 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {346 expect(url).toEqualEpsilon(0.0, CesiumMath.EPSILON11);347 // Just return any old image.348 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);349 });350 return provider.requestImage(3, 1, 2).then(function(image) {351 expect(Resource._Implementations.createImage).toHaveBeenCalled();352 expect(image).toBeInstanceOf(Image);353 });354 });355 });356 it('evaluates pattern westDegrees', function() {357 var provider = new UrlTemplateImageryProvider({358 url: '{westDegrees}',359 tilingScheme: new GeographicTilingScheme()360 });361 return pollToPromise(function() {362 return provider.ready;363 }).then(function() {364 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {365 expect(url).toEqualEpsilon(-45.0, CesiumMath.EPSILON11);366 // Just return any old image.367 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);368 });369 return provider.requestImage(3, 1, 2).then(function(image) {370 expect(Resource._Implementations.createImage).toHaveBeenCalled();371 expect(image).toBeInstanceOf(Image);372 });373 });374 });375 it('evaluates pattern northProjected', function() {376 var provider = new UrlTemplateImageryProvider({377 url: '{northProjected}',378 tilingScheme: new WebMercatorTilingScheme()379 });380 return pollToPromise(function() {381 return provider.ready;382 }).then(function() {383 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {384 expect(url).toEqualEpsilon(Math.PI * Ellipsoid.WGS84.maximumRadius / 2.0, CesiumMath.EPSILON11);385 // Just return any old image.386 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);387 });388 return provider.requestImage(3, 1, 2).then(function(image) {389 expect(Resource._Implementations.createImage).toHaveBeenCalled();390 expect(image).toBeInstanceOf(Image);391 });392 });393 });394 it('evaluates pattern southProjected', function() {395 var provider = new UrlTemplateImageryProvider({396 url: '{southProjected}'397 });398 return pollToPromise(function() {399 return provider.ready;400 }).then(function() {401 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {402 expect(url).toEqualEpsilon(Math.PI * Ellipsoid.WGS84.maximumRadius / 2.0, CesiumMath.EPSILON11);403 // Just return any old image.404 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);405 });406 return provider.requestImage(3, 0, 2).then(function(image) {407 expect(Resource._Implementations.createImage).toHaveBeenCalled();408 expect(image).toBeInstanceOf(Image);409 });410 });411 });412 it('evaluates pattern eastProjected', function() {413 var provider = new UrlTemplateImageryProvider({414 url: '{eastProjected}'415 });416 return pollToPromise(function() {417 return provider.ready;418 }).then(function() {419 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {420 expect(url).toEqualEpsilon(-Math.PI * Ellipsoid.WGS84.maximumRadius / 2.0, CesiumMath.EPSILON11);421 // Just return any old image.422 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);423 });424 return provider.requestImage(0, 1, 2).then(function(image) {425 expect(Resource._Implementations.createImage).toHaveBeenCalled();426 expect(image).toBeInstanceOf(Image);427 });428 });429 });430 it('evaluates pattern westProjected', function() {431 var provider = new UrlTemplateImageryProvider({432 url: '{westProjected}'433 });434 return pollToPromise(function() {435 return provider.ready;436 }).then(function() {437 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {438 expect(url).toEqualEpsilon(-Math.PI * Ellipsoid.WGS84.maximumRadius / 2.0, CesiumMath.EPSILON11);439 // Just return any old image.440 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);441 });442 return provider.requestImage(1, 1, 2).then(function(image) {443 expect(Resource._Implementations.createImage).toHaveBeenCalled();444 expect(image).toBeInstanceOf(Image);445 });446 });447 });448 it('evalutes multiple coordinate patterns', function() {449 var provider = new UrlTemplateImageryProvider({450 url: '{westDegrees} {westProjected} {southProjected} {southDegrees} {eastProjected} {eastDegrees} {northDegrees} {northProjected}'451 });452 return pollToPromise(function() {453 return provider.ready;454 }).then(function() {455 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {456 expect(url).toEqual(457 '-90 ' +458 (-Math.PI * Ellipsoid.WGS84.maximumRadius / 2.0) + ' ' +459 '0 ' +460 '0 ' +461 '0 ' +462 '0 ' +463 CesiumMath.toDegrees(WebMercatorProjection.mercatorAngleToGeodeticLatitude(Math.PI / 2)) + ' ' +464 (Math.PI * Ellipsoid.WGS84.maximumRadius / 2.0));465 // Just return any old image.466 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);467 });468 return provider.requestImage(1, 1, 2).then(function(image) {469 expect(Resource._Implementations.createImage).toHaveBeenCalled();470 expect(image).toBeInstanceOf(Image);471 });472 });473 });474 it('evaluates pattern s', function() {475 var provider = new UrlTemplateImageryProvider({476 url: '{s}'477 });478 return pollToPromise(function() {479 return provider.ready;480 }).then(function() {481 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {482 expect(['a', 'b', 'c'].indexOf(url)).toBeGreaterThanOrEqualTo(0);483 // Just return any old image.484 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);485 });486 return provider.requestImage(3, 1, 2).then(function(image) {487 expect(Resource._Implementations.createImage).toHaveBeenCalled();488 expect(image).toBeInstanceOf(Image);489 });490 });491 });492 it('uses custom subdomain string', function() {493 var provider = new UrlTemplateImageryProvider({494 url: '{s}',495 subdomains: '123'496 });497 return pollToPromise(function() {498 return provider.ready;499 }).then(function() {500 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {501 expect(['1', '2', '3'].indexOf(url)).toBeGreaterThanOrEqualTo(0);502 // Just return any old image.503 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);504 });505 return provider.requestImage(3, 1, 2).then(function(image) {506 expect(Resource._Implementations.createImage).toHaveBeenCalled();507 expect(image).toBeInstanceOf(Image);508 });509 });510 });511 it('uses custom subdomain array', function() {512 var provider = new UrlTemplateImageryProvider({513 url: '{s}',514 subdomains: ['foo', 'bar']515 });516 return pollToPromise(function() {517 return provider.ready;518 }).then(function() {519 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {520 expect(['foo', 'bar'].indexOf(url)).toBeGreaterThanOrEqualTo(0);521 // Just return any old image.522 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);523 });524 return provider.requestImage(3, 1, 2).then(function(image) {525 expect(Resource._Implementations.createImage).toHaveBeenCalled();526 expect(image).toBeInstanceOf(Image);527 });528 });529 });530 it('uses custom tags', function() {531 var provider = new UrlTemplateImageryProvider({532 url: 'made/up/tms/server/{custom1}/{custom2}/{z}/{y}/{x}.PNG',533 tilingScheme: new GeographicTilingScheme(),534 maximumLevel: 6,535 customTags: {536 custom1: function() { return 'foo';},537 custom2: function() { return 'bar';}538 }539 });540 return pollToPromise(function() {541 return provider.ready;542 }).then(function() {543 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {544 expect(url).toEqual('made/up/tms/server/foo/bar/2/1/3.PNG');545 // Just return any old image.546 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);547 });548 return provider.requestImage(3, 1, 2).then(function(image) {549 expect(Resource._Implementations.createImage).toHaveBeenCalled();550 expect(image).toBeInstanceOf(Image);551 });552 });553 });554 describe('pickFeatures', function() {555 it('returns undefined when enablePickFeatures is false', function() {556 var provider = new UrlTemplateImageryProvider({557 url: 'foo/bar',558 pickFeaturesUrl: 'foo/bar',559 getFeatureInfoFormats: [560 new GetFeatureInfoFormat('json', 'application/json'),...
MapboxImageryProviderSpec.js
Source:MapboxImageryProviderSpec.js
...83 }).then(function() {84 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {85 expect(url).not.toContain('//');86 // Just return any old image.87 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);88 });89 return provider.requestImage(0, 0, 0).then(function(image) {90 expect(Resource._Implementations.createImage).toHaveBeenCalled();91 expect(image).toBeInstanceOf(Image);92 });93 });94 });95 it('supports no slash at the endof the URL', function() {96 var provider = new MapboxImageryProvider({97 url : 'made/up/mapbox/server',98 mapId: 'test-id'99 });100 return pollToPromise(function() {101 return provider.ready;102 }).then(function() {103 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {104 expect(url).toContain('made/up/mapbox/server/');105 // Just return any old image.106 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);107 });108 return provider.requestImage(0, 0, 0).then(function(image) {109 expect(Resource._Implementations.createImage).toHaveBeenCalled();110 expect(image).toBeInstanceOf(Image);111 });112 });113 });114 it('requestImage returns a promise for an image and loads it for cross-origin use', function() {115 var provider = new MapboxImageryProvider({116 url : 'made/up/mapbox/server/',117 mapId: 'test-id'118 });119 expect(provider.url).toEqual('made/up/mapbox/server/');120 return pollToPromise(function() {121 return provider.ready;122 }).then(function() {123 expect(provider.tileWidth).toEqual(256);124 expect(provider.tileHeight).toEqual(256);125 expect(provider.maximumLevel).toBeUndefined();126 expect(provider.tilingScheme).toBeInstanceOf(WebMercatorTilingScheme);127 expect(provider.rectangle).toEqual(new WebMercatorTilingScheme().rectangle);128 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {129 // Just return any old image.130 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);131 });132 return provider.requestImage(0, 0, 0).then(function(image) {133 expect(Resource._Implementations.createImage).toHaveBeenCalled();134 expect(image).toBeInstanceOf(Image);135 });136 });137 });138 it('rectangle passed to constructor does not affect tile numbering', function() {139 var rectangle = new Rectangle(0.1, 0.2, 0.3, 0.4);140 var provider = new MapboxImageryProvider({141 url : 'made/up/mapbox/server/',142 mapId: 'test-id',143 rectangle : rectangle144 });145 return pollToPromise(function() {146 return provider.ready;147 }).then(function() {148 expect(provider.tileWidth).toEqual(256);149 expect(provider.tileHeight).toEqual(256);150 expect(provider.maximumLevel).toBeUndefined();151 expect(provider.tilingScheme).toBeInstanceOf(WebMercatorTilingScheme);152 expect(provider.rectangle).toEqualEpsilon(rectangle, CesiumMath.EPSILON14);153 expect(provider.tileDiscardPolicy).toBeUndefined();154 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {155 expect(url).toContain('/0/0/0');156 // Just return any old image.157 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);158 });159 return provider.requestImage(0, 0, 0).then(function(image) {160 expect(Resource._Implementations.createImage).toHaveBeenCalled();161 expect(image).toBeInstanceOf(Image);162 });163 });164 });165 it('uses maximumLevel passed to constructor', function() {166 var provider = new MapboxImageryProvider({167 url : 'made/up/mapbox/server/',168 mapId: 'test-id',169 maximumLevel : 5170 });171 expect(provider.maximumLevel).toEqual(5);172 });173 it('uses minimumLevel passed to constructor', function() {174 var provider = new MapboxImageryProvider({175 url : 'made/up/mapbox/server/',176 mapId: 'test-id',177 minimumLevel : 1178 });179 expect(provider.minimumLevel).toEqual(1);180 });181 it('when no credit is supplied, the provider adds a default credit', function() {182 var provider = new MapboxImageryProvider({183 url : 'made/up/mapbox/server/',184 mapId: 'test-id'185 });186 expect(provider.credit).toBe(MapboxImageryProvider._defaultCredit);187 });188 it('turns the supplied credit into a logo', function() {189 var creditText = 'Thanks to our awesome made up source of this imagery!';190 var providerWithCredit = new MapboxImageryProvider({191 url : 'made/up/mapbox/server/',192 mapId: 'test-id',193 credit: creditText194 });195 expect(providerWithCredit.credit.html).toEqual(creditText);196 });197 it('raises error event when image cannot be loaded', function() {198 var provider = new MapboxImageryProvider({199 url : 'made/up/mapbox/server/',200 mapId: 'test-id'201 });202 var layer = new ImageryLayer(provider);203 var tries = 0;204 provider.errorEvent.addEventListener(function(error) {205 expect(error.timesRetried).toEqual(tries);206 ++tries;207 if (tries < 3) {208 error.retry = true;209 }210 setTimeout(function() {211 RequestScheduler.update();212 }, 1);213 });214 Resource._Implementations.createImage = function(url, crossOrigin, deferred) {215 if (tries === 2) {216 // Succeed after 2 tries217 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);218 } else {219 // fail220 setTimeout(function() {221 deferred.reject();222 }, 1);223 }224 };225 return pollToPromise(function() {226 return provider.ready;227 }).then(function() {228 var imagery = new Imagery(layer, 0, 0, 0);229 imagery.addReference();230 layer._requestImagery(imagery);231 RequestScheduler.update();232 return pollToPromise(function() {233 return imagery.state === ImageryState.RECEIVED;234 }).then(function() {235 expect(imagery.image).toBeInstanceOf(Image);236 expect(tries).toEqual(2);237 imagery.releaseReference();238 });239 });240 });241 it('appends specified format', function() {242 var provider = new MapboxImageryProvider({243 url : 'made/up/mapbox/server/',244 mapId: 'test-id',245 format: '@2x.png'246 });247 return pollToPromise(function() {248 return provider.ready;249 }).then(function() {250 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {251 expect(/made\/up\/mapbox\/server\/test-id\/0\/0\/0@2x\.png\?access_token=/.test(url)).toBe(true);252 // Just return any old image.253 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);254 });255 return provider.requestImage(0, 0, 0).then(function(image) {256 expect(Resource._Implementations.createImage).toHaveBeenCalled();257 });258 });259 });260 it('adds missing period for format', function() {261 var provider = new MapboxImageryProvider({262 url : 'made/up/mapbox/server/',263 mapId: 'test-id',264 format: 'png'265 });266 return pollToPromise(function() {267 return provider.ready;268 }).then(function() {269 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {270 expect(/made\/up\/mapbox\/server\/test-id\/0\/0\/0\.png\?access_token=/.test(url)).toBe(true);271 // Just return any old image.272 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);273 });274 return provider.requestImage(0, 0, 0).then(function(image) {275 expect(Resource._Implementations.createImage).toHaveBeenCalled();276 });277 });278 });...
createOpenStreetMapImageryProviderSpec.js
Source:createOpenStreetMapImageryProviderSpec.js
...57 }).then(function() {58 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {59 expect(url).not.toContain('//');60 // Just return any old image.61 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);62 });63 return provider.requestImage(0, 0, 0).then(function(image) {64 expect(Resource._Implementations.createImage).toHaveBeenCalled();65 expect(image).toBeInstanceOf(Image);66 });67 });68 });69 it('supports a slash at the end of the URL', function() {70 var provider = createOpenStreetMapImageryProvider({71 url : 'made/up/osm/server/'72 });73 return pollToPromise(function() {74 return provider.ready;75 }).then(function() {76 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {77 expect(url).not.toContain('//');78 // Just return any old image.79 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);80 });81 return provider.requestImage(0, 0, 0).then(function(image) {82 expect(Resource._Implementations.createImage).toHaveBeenCalled();83 expect(image).toBeInstanceOf(Image);84 });85 });86 });87 it('supports no slash at the endof the URL', function() {88 var provider = createOpenStreetMapImageryProvider({89 url : 'made/up/osm/server'90 });91 return pollToPromise(function() {92 return provider.ready;93 }).then(function() {94 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {95 expect(url).toContain('made/up/osm/server/');96 // Just return any old image.97 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);98 });99 return provider.requestImage(0, 0, 0).then(function(image) {100 expect(Resource._Implementations.createImage).toHaveBeenCalled();101 expect(image).toBeInstanceOf(Image);102 });103 });104 });105 it('requestImage returns a promise for an image and loads it for cross-origin use', function() {106 var provider = createOpenStreetMapImageryProvider({107 url : 'made/up/osm/server/'108 });109 expect(provider.url).toContain('made/up/osm/server/');110 return pollToPromise(function() {111 return provider.ready;112 }).then(function() {113 expect(provider.tileWidth).toEqual(256);114 expect(provider.tileHeight).toEqual(256);115 expect(provider.maximumLevel).toBeUndefined();116 expect(provider.tilingScheme).toBeInstanceOf(WebMercatorTilingScheme);117 expect(provider.rectangle).toEqual(new WebMercatorTilingScheme().rectangle);118 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {119 // Just return any old image.120 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);121 });122 return provider.requestImage(0, 0, 0).then(function(image) {123 expect(Resource._Implementations.createImage).toHaveBeenCalled();124 expect(image).toBeInstanceOf(Image);125 });126 });127 });128 it('when no credit is supplied, a default one is used', function() {129 var provider = createOpenStreetMapImageryProvider({130 url : 'made/up/osm/server'131 });132 expect(provider.credit).toBeDefined();133 });134 it('turns the supplied credit into a logo', function() {135 var providerWithCredit = createOpenStreetMapImageryProvider({136 url : 'made/up/osm/server',137 credit : 'Thanks to our awesome made up source of this imagery!'138 });139 expect(providerWithCredit.credit).toBeDefined();140 });141 it('rectangle passed to constructor does not affect tile numbering', function() {142 var rectangle = new Rectangle(0.1, 0.2, 0.3, 0.4);143 var provider = createOpenStreetMapImageryProvider({144 url : 'made/up/osm/server',145 rectangle : rectangle146 });147 return pollToPromise(function() {148 return provider.ready;149 }).then(function() {150 expect(provider.tileWidth).toEqual(256);151 expect(provider.tileHeight).toEqual(256);152 expect(provider.maximumLevel).toBeUndefined();153 expect(provider.tilingScheme).toBeInstanceOf(WebMercatorTilingScheme);154 expect(provider.rectangle.west).toBeCloseTo(rectangle.west, CesiumMath.EPSILON10);155 expect(provider.rectangle.south).toBeCloseTo(rectangle.south, CesiumMath.EPSILON10);156 expect(provider.rectangle.east).toBeCloseTo(rectangle.east, CesiumMath.EPSILON10);157 expect(provider.rectangle.north).toBeCloseTo(rectangle.north, CesiumMath.EPSILON10);158 expect(provider.tileDiscardPolicy).toBeUndefined();159 spyOn(Resource._Implementations, 'createImage').and.callFake(function(url, crossOrigin, deferred) {160 expect(url).toContain('/0/0/0');161 // Just return any old image.162 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);163 });164 return provider.requestImage(0, 0, 0).then(function(image) {165 expect(Resource._Implementations.createImage).toHaveBeenCalled();166 expect(image).toBeInstanceOf(Image);167 });168 });169 });170 it('uses maximumLevel passed to constructor', function() {171 var provider = createOpenStreetMapImageryProvider({172 url : 'made/up/osm/server',173 maximumLevel : 5174 });175 expect(provider.maximumLevel).toEqual(5);176 });177 it('uses minimumLevel passed to constructor', function() {178 var provider = createOpenStreetMapImageryProvider({179 url : 'made/up/osm/server',180 minimumLevel : 1181 });182 expect(provider.minimumLevel).toEqual(1);183 });184 it('raises error event when image cannot be loaded', function() {185 var provider = createOpenStreetMapImageryProvider({186 url : 'made/up/osm/server'187 });188 var layer = new ImageryLayer(provider);189 var tries = 0;190 provider.errorEvent.addEventListener(function(error) {191 expect(error.timesRetried).toEqual(tries);192 ++tries;193 if (tries < 3) {194 error.retry = true;195 }196 setTimeout(function() {197 RequestScheduler.update();198 }, 1);199 });200 Resource._Implementations.createImage = function(url, crossOrigin, deferred) {201 if (tries === 2) {202 // Succeed after 2 tries203 Resource._DefaultImplementations.createImage('Data/Images/Red16x16.png', crossOrigin, deferred);204 } else {205 // fail206 setTimeout(function() {207 deferred.reject();208 }, 1);209 }210 };211 return pollToPromise(function() {212 return provider.ready;213 }).then(function() {214 var imagery = new Imagery(layer, 0, 0, 0);215 imagery.addReference();216 layer._requestImagery(imagery);217 RequestScheduler.update();...
images.js
Source:images.js
...10 renderImgs(gImgs);11}12function createImgs() {13 var imgs = [];14 imgs.push(createImage('./img/gallery/Oprah-You-Get-A.jpg', ['happy']),15 createImage('./img/gallery/One-Does-Not-Simply.jpg', ['fun']),16 createImage('./img/gallery/Ancient-Aliens.jpg', ['happy']),17 createImage('./img/gallery/Batman-Slapping-Robin.jpg', ['happy']),18 createImage('./img/gallery/Mocking-Spongebob.jpg', ['happy']),19 createImage('./img/gallery/success.jpg', ['happy']),20 createImage('./img/gallery/X-Everywhere.jpg', ['sad']),21 createImage('./img/gallery/Drake-Hotline-Bling.jpg',['sad']),22 createImage('./img/gallery/1kwmfp.jpg', ['sad']),23 createImage('./img/gallery/3ks7.jpg', ['sad']),24 createImage('./img/gallery/10-Guy.jpg', ['sad']),25 createImage('./img/gallery/72745676.jpg', ['sad']),26 createImage('./img/gallery/Afraid-To-Ask-Andy.jpg', ['sad']),27 createImage('./img/gallery/Am-I-The-Only-One-Around-Here.jpg', ['sad']),28 createImage('./img/gallery/Bad-Luck-Brian.jpg', ['sad']),29 createImage('./img/gallery/Black-Girl-Wat.jpg', ['sad']),30 createImage('./img/gallery/Blank-Nut-Button.jpg', ['sad']),31 createImage('./img/gallery/Boardroom-Meeting-Suggestion.jpg', ['sad']),32 createImage('./img/gallery/Brace-Yourselves-X-is-Coming.jpg', ['sad']),33 createImage('./img/gallery/bpffa.jpg', ['sad']),34 createImage('./img/gallery/Captain-Picard-Facepalm.jpg', ['sad']),35 createImage('./img/gallery/Change-My-Mind.jpg', ['sad']),36 createImage('./img/gallery/Creepy-Condescending-Wonka.jpg', ['sad']),37 createImage('./img/gallery/Disaster-Girl.jpg', ['sad']),38 createImage('./img/gallery/Distracted-Boyfriend.jpg', ['sad']),39 createImage('./img/gallery/Expanding-Brain.jpg', ['sad']),40 createImage('./img/gallery/Face-You-Make-Robert-Downey-Jr.jpg', ['sad']),41 createImage('./img/gallery/Finding-Neverland.jpg', ['sad']),42 createImage('./img/gallery/Grumpy-Cat.jpg', ['sad']),43 createImage('./img/gallery/guywithcup.jpg', ['sad']),44 createImage('./img/gallery/Hard-To-Swallow-Pills.jpg', ['sad']),45 createImage('./img/gallery/If-You-Know-What-I-Mean-Bean.jpg', ['sad']),46 createImage('./img/gallery/I-Know-That-Feel-Bro.jpg', ['sad']),47 createImage('./img/gallery/Is-This-A-Pigeon.jpg', ['sad']),48 createImage('./img/gallery/Its-Finally-Over.jpg', ['sad']),49 createImage('./img/gallery/Laughing-Men-In-Suits.jpg', ['sad']),50 createImage('./img/gallery/Left-Exit-12-Off-Ramp.jpg', ['sad']),51 createImage('./img/gallery/Leonardo-Dicaprio-Cheers.jpg', ['sad']),52 createImage('./img/gallery/Liam-Neeson-Taken-2.jpg', ['sad']),53 createImage('./img/gallery/Marked-Safe-From.jpg', ['sad']),54 createImage('./img/gallery/Me-And-The-Boys.jpg', ['sad']),55 createImage('./img/gallery/Mocking-Spongebob.jpg', ['sad']),56 createImage('./img/gallery/nigga.jpg', ['sad']),57 createImage('./img/gallery/Philosoraptor.jpg', ['sad']),58 createImage('./img/gallery/qby413sh1v711.png', ['sad']),59 createImage('./img/gallery/Roll-Safe-Think-About-It.jpg', ['sad']),60 createImage('./img/gallery/Running-Away-Balloon.jpg', ['sad']),61 createImage('./img/gallery/shutupandtakemymoney.png', ['sad']),62 createImage('./img/gallery/Surprised-Pikachu.jpg', ['sad']),63 createImage('./img/gallery/The-Rock-Driving.jpg', ['sad']),64 createImage('./img/gallery/Trump-Bill-Signing.jpg', ['sad']),65 createImage('./img/gallery/Two-Buttons.jpg', ['sad']),66 createImage('./img/gallery/X-All-The-Y.jpg', ['sad']),67 createImage('./img/gallery/Yall-Got-Any-More-Of-That.jpg', ['sad']),68 createImage('./img/gallery/3a3.jpg', ['sad']),69 createImage('./img/gallery/waiting-skeleton.jpg', ['sad']),70 createImage('./img/gallery/18bzwy.jpg', ['sad']),71 createImage('./img/gallery/184vq8.jpg', ['sad']),72 createImage('./img/gallery/2g1j3o.jpg', ['sad']),73 createImage('./img/gallery/2l8ijj.jpg', ['sad']),74 createImage('./img/gallery/3snea.jpg', ['sad']),75 createImage('./img/gallery/Tuxedo-Winnie-The-Pooh.png', ['sad']),76 createImage('./img/gallery/2xexq8.png', ['sad']),77 createImage('./img/gallery/The-Scroll-Of-Truth.jpg', ['sad']),78 createImage('./img/gallery/The-Most-Interesting-Man-In-The-World.jpg', ['sad']),79 createImage('./img/gallery/1rzy4a.jpg', ['sad']),80 createImage('./img/gallery/That-Would-Be-Great.jpg', ['sad']),81 createImage('./img/gallery/1e9phd.jpg', ['sad']),82 createImage('./img/gallery/b13tc.jpg', ['sad']),83 createImage('./img/gallery/First-World-Problems.jpg', ['sad']),84 createImage('./img/gallery/Who-Would-Win.jpg', ['sad']),85 createImage('./img/gallery/Grandma-Finds-The-Internet.jpg', ['sad']),86 createImage('./img/gallery/But-Thats-None-Of-My-Business.jpg', ['sad']),87 createImage('./img/gallery/Y-U-No.jpg', ['sad']),88 createImage('./img/gallery/Star-Wars-Yoda.jpg', ['sad']),89 createImage('./img/gallery/Dr-Evil-Laser.jpg', ['sad']),90 createImage('./img/gallery/Evil-Toddler.jpg', ['sad']),91 createImage('./img/gallery/Sleeping-Shaq.jpg', ['sad']),92 createImage('./img/gallery/9n1nu.jpg', ['sad']),93 createImage('./img/gallery/jse4v.jpg', ['sad']),94 createImage('./img/gallery/Back-In-My-Day.jpg', ['sad']),95 createImage('./img/gallery/167ev8.jpg', ['sad']),96 createImage('./img/gallery/Consuela.jpg', ['sad']),97 createImage('./img/gallery/Sad-Keanu.jpg', ['sad']));98 return imgs;99}100function createImage(url, keywords) {101 return {102 id: gNextId++,103 url: url,104 keywords: keywords105 };106}107function renderImgs(imgs) {108 var strHtml = imgs.map(function (img, idx) {109 return `110 <img id='${img.id}' src='${img.url}' onclick="initMemeEditor(${img.id},this)" alt='meme picture'/>111 `112 })113 .join(' ')114 ...
createScreen.js
Source:createScreen.js
...5 //Header6 createText(svg, '70', '50', '25', 'none', 'Segoe UI', '#B0BDD7', 'Start', true);7 createText(svg, '790', '45', '15', 'none', 'Segoe UI', '#B0BDD7', 'Richard', true)8 createText(svg, '816', '55', '10', 'none', 'Segoe UI', '#B0BDD7', 'Perry', true) 9 createImage(svg, '845', '33', '25', '25', 'images/MikeGibbs.jpg', true);10 //first row:11 createRect(svg, '70', '100', '85', '90', '#2776ec', 'none', true); 12 createImage(svg, '85', '115', '55', '50', 'images/store.png');13 createText(svg, '80', '185', '9', 'none', 'Segoe UI', '#fff', 'Store'), 14 createRect(svg, '165', '100', '85', '90', '#69b71d', 'none', true);15 createImage(svg, '177', '105', '60', '65', 'images/XboxLiveGames.png');16 createText(svg, '175', '185', '9', 'none', 'Segoe UI', '#fff', 'Xbox LIVE Games');17 createRect(svg, '260', '100', '165', '90', '#af1b3d', 'none', true);18 createImage(svg, '315', '115', '45', '50', 'images/photos.png');19 createText(svg, '270', '185', '9', 'none', 'Segoe UI', '#fff', 'Photos');20 createRect(svg, '435', '100', '190', '90', '#009418', 'none', true);21 createText(svg, '550', '150', '50', 'none', 'Segoe UI', '#fff', '12');22 createText(svg, '547', '160', '10', 'none', 'Segoe UI', '#fff', 'Monday');23 createText(svg, '445', '185', '9', 'none', 'Segoe UI', '#fff', 'Calendar');24 createRect(svg, '655', '100', '165', '90', '#5334ac', 'none', true);25 createImage(svg, '710', '115', '45', '50', 'images/music.png');26 createText(svg, '665', '185', '9', 'none', 'Segoe UI', '#fff', 'Music');27 createImage(svg, '815', '100', '100', '90', 'images/2s.jpg');28 //Second row29 createRect(svg, '70', '200', '85', '90', '#5334ac', 'none', true);30 createImage(svg, '85', '215', '55', '50', 'images/maps.png');31 createText(svg, '80', '285', '9', 'none', 'Segoe UI', '#fff', 'Maps'),32 createRect(svg, '165', '200', '85', '90', '#2776ec', 'none', true);33 createImage(svg, '177', '205', '60', '65', 'images/IE.png');34 createText(svg, '175', '285', '9', 'none', 'Segoe UI', '#fff', 'Internet Explorer');35 createRect(svg, '260', '200', '165', '90', '#5334ac', 'none', true);36 createImage(svg, '305', '195', '85', '90', 'images/message.png');37 createText(svg, '270', '285', '9', 'none', 'Segoe UI', '#fff', 'Messaging');//38 createRect(svg, '435', '200', '190', '90', '#d9512b', 'none', true);39 createImage(svg, '445', '210', '40', '45', 'images/MikeGibbs.jpg');40 createText(svg, '490', '222', '9', 'none', 'Segoe UI', '#B0BDD7', 'Mike Gibs, Troll Scout');41 createText(svg, '490', '232', '9', 'none', 'Segoe UI', '#B0BDD7', 'and 5 others commented');42 createText(svg, '490', '242', '9', 'none', 'Segoe UI', '#B0BDD7', 'on your photo');43 createImage(svg, '445', '260', '30', '30', 'images/ppl.png');44 createRect(svg, '655', '200', '165', '90', '#009418', 'none', true);45 createImage(svg, '710', '215', '45', '50', 'images/finance.png');46 createText(svg, '665', '285', '9', 'none', 'Segoe UI', '#fff', 'Finance');47 createRect(svg, '830', '200', '100', '90', '#0061a6', 'none', true);48 createImage(svg, '835', '210', '70', '70', 'images/pinguin.png');49 //Third row50 createRect(svg, '70', '300', '180', '90', '#d9512b', 'none', true);51 createImage(svg, '130', '315', '55', '50', 'images/video.png');52 createText(svg, '80', '385', '9', 'none', 'Segoe UI', '#fff', 'Video'),53 createRect(svg, '260', '300', '165', '90', '#009418', 'none', true);54 createText(svg, '270', '320', '15', 'none', 'Segoe UI', '#B0BDD7', 'Devon Hipnotize');55 createText(svg, '270', '330', '10', 'none', 'Segoe UI', '#B0BDD7', 'something they can do about him');56 createText(svg, '270', '340', '10', 'none', 'Segoe UI', '#B0BDD7', 'pile of books and scrools next to');57 createImage(svg, '265', '355', '35', '40', 'images/letter.png');58 createText(svg, '405', '385', '9', 'none', 'Segoe UI', '#fff', '3');59 createImage(svg, '435', '297', '90', '97', 'images/Pinball.jpg');60 createImage(svg, '535', '295', '90', '100', 'images/solitaire.png');61 62 createRect(svg, '655', '300', '77', '90', '#d9512b', 'none', true);63 createImage(svg, '670', '315', '45', '50', 'images/reader.png');64 createText(svg, '665', '385', '9', 'none', 'Segoe UI', '#fff', 'Reader');65 createRect(svg, '743', '300', '77', '90', '#01296e', 'none', true);66 createText(svg, '753', '325', '14', 'none', 'Segoe UI', '#B0BDD7', 'Windows');67 createText(svg, '753', '340', '14', 'none', 'Segoe UI', '#B0BDD7', 'Explorer');68 createImage(svg, '753', '360', '25', '25', 'images/WindowsExplorer.png');69 createRect(svg, '830', '300', '100', '90', '#2877ed', 'none', true);70 createImage(svg, '835', '310', '70', '70', 'images/skyDrive.png');71 createText(svg, '840', '385', '9', 'none', 'Segoe UI', '#B0BDD7', 'SkyDrive');72 //Fourth row73 createRect(svg, '70', '400', '180', '90', '#297c86', 'none', true);74 createImage(svg, '130', '415', '55', '50', 'images/Fish.png');75 createText(svg, '80', '485', '9', 'none', 'Segoe UI', '#fff', 'Desktop'),76 createRect(svg, '260', '400', '165', '90', '#2877ed', 'none', true);77 createImage(svg, '315', '415', '55', '50', 'images/weather.png');78 createText(svg, '270', '485', '9', 'none', 'Segoe UI', '#fff', 'Weather');79 createRect(svg, '435', '400', '90', '90', '#af1b3d', 'none', true);80 createImage(svg, '450', '415', '65', '60', 'images/camera.png');81 createText(svg, '445', '485', '9', 'none', 'Segoe UI', '#fff', 'Camera');82 83 createRect(svg, '535', '400', '90', '90', '#69b71d', 'none', true);84 createImage(svg, '550', '415', '55', '50', 'images/XboxCompanion.png');85 createText(svg, '545', '485', '9', 'none', 'Segoe UI', '#fff', 'Xbox Companion');86 createImage(svg, '655', '340', '170', '210', 'images/WordPress.jpg');...
main-service.js
Source:main-service.js
...6function createImages() {7 let imgs = getValue('allImages')8 if (!imgs || !imgs.length) {9 imgs = [10 createImage('imgs/2.jpg', ['happy', 'nature']),11 createImage('imgs/5.jpg', ['baby', 'success']),12 createImage('imgs/8.jpg', ['condescending', 'wonka']),13 createImage('imgs/9.jpg', ['evil', 'baby', 'cunning']),14 createImage('imgs/img11.jpg', ['laughing', 'satisfied']),15 createImage('imgs/img12.jpg', ['kissing', 'fighters']),16 createImage('imgs/img6.jpg', ['tired', 'dog']),17 createImage('imgs/003.jpg', ['trump', 'orange', 'vain', 'angry']),18 createImage('imgs/004.jpg', ['dog', 'cute', 'love', 'sweet']),19 createImage('imgs/005.jpg', ['dog', 'baby', 'sleep', 'cute', 'smile', 'bed']),20 createImage('imgs/006.jpg', ['cat', 'sleep', 'computer']),21 createImage('imgs/12.jpg', ['blaming', 'finger']),22 createImage('imgs/Ancient-Aliens.jpg', ['if', 'history', 'aliens', 'let me explain']),23 createImage('imgs/drevil.jpg', ['evil', 'quotes', 'fake', 'powers']),24 createImage('imgs/img2.jpg', ['africa', 'baby', 'dance', 'fun', 'naked']),25 createImage('imgs/img5.jpg', ['baby', 'surprise', 'funny', 'cute']),26 createImage('imgs/leo.jpg', ['leo dicaprio', 'salute', 'cheers', 'fancy']),27 createImage('imgs/meme1.jpg', ['matrix', 'what if', 'serious']),28 createImage('imgs/meme2.jpg', ['one does not', 'game thrones', 'sean', 'explain']),29 createImage('imgs/meme3.jpg', ['oprah', 'you get', 'shout']),30 createImage('imgs/patrick.jpg', ['patrick', 'holding', 'laugh', 'cry']),31 createImage('imgs/putin.jpg', ['putin', 'two', 'strong', 'russia']),32 createImage('imgs/meme4.jpg', ['toy story', 'two', 'buzz', 'cowboy', 'stars', 'look']),33 createImage('imgs/russian.jpg', ['russian', 'badass', 'sexy', 'beer']),34 createImage('imgs/arm-wrestle.png', ['strong', 'muscle', 'black', 'white', 'arm wrestle']),35 createImage('imgs/meme5.jpg', ['thinking', 'know best', 'black', 'use mind']),36 createImage('imgs/tyson.jpg', ['not fault', 'draw', 'not mine', 'suspicious']),37 createImage('imgs/grandma.jpg', ['grandma', 'cant see', 'glasses', 'backwords', 'understand']),38 createImage('imgs/office.jpg', ['office', 'coffee', 'spandex']),39 createImage('imgs/grylls.jpg', ['bear', 'grylls', 'improvise', 'adapt', 'overcome']),40 createImage('imgs/ohno.jpg', ['stress', 'what to push', 'sweat', 'pressure', 'bomb']),41 createImage('imgs/drake.jpg', ['yes', 'no', 'oh', 'feel good', 'dance']),42 createImage('imgs/keanu.jpg', ['keanu', 'reeves', 'shit', 'wtf', 'confused']),43 createImage('imgs/joker.jpg', ['joker', 'batman', 'lose mine', 'bat an eye', 'crazy']),44 createImage('imgs/jackson.jpg', ['i just came here', 'outsider', 'enjoying', 'gloating', 'movie']),45 createImage('imgs/stoned.jpg', ['satisfied', 'happy', 'smoke']),46 createImage('imgs/hart.jpg', ['kevin', 'hart', 'not shit', 'whats that', 'microphone']),47 createImage('imgs/crying.jpg', ['crying', 'sad', 'oh', 'feel bad']),48 createImage('imgs/feel-good.jpg', ['feel good', 'oh', 'smooth', 'bald', 'draw']),49 createImage('imgs/troll.jpg', ['overattached', 'girlfriend', 'troll', 'creepy', 'webcam']),50 createImage('imgs/piece.jpg', ['boyfriend', 'girlfriend', 'looking', 'ass', 'creepy']),51 createImage('imgs/money.jpg', ['shut up', 'take', 'money']),52 createImage('imgs/eternal.jpg', ['creepy', 'oldschool', 'geek', 'noob', 'braces']),53 createImage('imgs/anime-meme.jpg', ['suspicious', 'futurama', 'stupid', 'anime']),54 ]55 }56 gImgs = imgs;57 saveValue('allImages', gImgs)58 return imgs;59}60function createImage(url, words) {61 let img = {62 id: gId++,63 keywords: words,64 imgUrl: url65 }66 return img;67}68function getImgById(id) {69 return gImgs.find(img => {70 return img.id === id;71 })72}73function getSearchedMemes(searchStr) {74 return gImgs.filter(img => {...
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const image = await page.createImage();7 await image.saveAs('/tmp/test.png');8 await browser.close();9})();
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const image = await page.screenshot({ fullPage: true });7 await browser.close();8 console.log(image);9})();
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const image = await page.screenshot({ fullPage: true });7 await page.createImage(image, { path: 'image.png' });8 await browser.close();9})();10Recommended Posts: Playwright | Using createPDF() Method11Playwright | Using createHar() Method12Playwright | Using createTrace() Method
Using AI Code Generation
1const { webkit } = require('playwright');2const fs = require('fs');3(async () => {4 const browser = await webkit.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const image = await page.screenshot({ path: 'google.png' });8 await browser.close();9})();10const { webkit } = require('playwright');11const fs = require('fs');12(async () => {13 const browser = await webkit.launch();14 const context = await browser.newContext();15 const page = await context.newPage();16 const image = await page.screenshot({ path: 'google.png' });17 await browser.close();18})();19const { webkit } = require('playwright');20const fs = require('fs');21(async () => {22 const browser = await webkit.launch();23 const context = await browser.newContext();24 const page = await context.newPage();25 const image = await page.screenshot({ path: 'google.png' });26 await browser.close();27})();28const { webkit } = require('playwright');29const fs = require('fs');30(async () => {31 const browser = await webkit.launch();32 const context = await browser.newContext();33 const page = await context.newPage();34 const image = await page.screenshot({ path: 'google.png' });35 await browser.close();36})();37const { webkit } = require('playwright');38const fs = require('fs');39(async () => {40 const browser = await webkit.launch();41 const context = await browser.newContext();42 const page = await context.newPage();43 const image = await page.screenshot({ path: 'google.png' });44 await browser.close();45})();
Using AI Code Generation
1const { createImage } = require('playwright-core/lib/server/supplements/recorder/recorderApp');2const {chromium} = require('playwright-core');3const fs = require('fs');4const path = require('path');5(async () => {6 const browser = await chromium.launch();7 const page = await browser.newPage();8 const element = await page.$('h1');9 const image = await createImage(element, 'png', 1);10 fs.writeFileSync(path.join(__dirname, 'image.png'), image);11 await browser.close();12})();13 at CDPSession.send (/home/raghav/Projects/playwright-test/node_modules/playwright-core/lib/cjs/pw-run.js:172:13)14 at DOMWorld._document (/home/raghav/Projects/playwright-test/node_modules/playwright-core/lib/cjs/pw-run.js:104:53)15 at DOMWorld._documentPromise (/home/raghav/Projects/playwright-test/node_modules/playwright-core/lib/cjs/pw-run.js:98:18)16 at DOMWorld.evaluateHandle (/home/raghav/Projects/playwright-test/node_modules/playwright-core/lib/cjs/pw-run.js:327:25)17 at DOMWorld.evaluate (/home/raghav/Projects/playwright-test/node_modules/playwright-core/lib/cjs/pw-run.js:309:17)18 at Page._document (/home/raghav/Projects/playwright-test/node_modules/playwright-core/lib/cjs/pw-run.js:104:53)19 at Page._documentPromise (/home/raghav/Projects/playwright-test/node_modules/playwright-core/lib/cjs/pw-run.js:98:18)20 at Page.evaluateHandle (/home/raghav/Projects/playwright-test/node_modules/playwright-core/lib/cjs/pw-run.js:327:25)21 at Page.evaluate (/home/raghav/Projects/playwright-test/node_modules/playwright-core/lib/cjs/pw-run.js:309:17)22 at Page.$ (/home/raghav/Projects/playwright-test/node_modules/playwright-core/lib/cjs/pw-run.js:515:22)
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const image = await page.screenshot();7 require('fs').writeFileSync('example.png', image);8 await browser.close();9})();10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const context = await browser.newContext();14 const page = await context.newPage();15 const image = await page.screenshot();16 require('fs').writeFileSync('example.png', image);17 await browser.close();18})();19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const context = await browser.newContext();23 const page = await context.newPage();24 const image = await page.screenshot();25 require('fs').writeFileSync('example.png', image);26 await browser.close();27})();28const { chromium } = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const context = await browser.newContext();32 const page = await context.newPage();33 const image = await page.screenshot();34 require('fs').writeFileSync('example.png', image);35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch();
Using AI Code Generation
1const { createImage } = require('@playwright/test/lib/server/chromium/crBrowser');2const browser = await chromium.launch();3const page = await browser.newPage();4});5await browser.close();6fs.writeFileSync('image.jpeg', image);7fs.writeFileSync('image.png', image);8fs.writeFileSync('image.webp', image);
Using AI Code Generation
1const { createImage } = require('playwright-core/lib/server/supplements/recorder/recorderApp');2const image = createImage();3console.log(image);4const { createImage } = require('playwright-core/lib/server/supplements/recorder/recorderApp');5const image = createImage();6console.log(image);7const { createImage } = require('playwright-core/lib/server/supplements/recorder/recorderApp');8const image = createImage();9console.log(image);10const { createImage } = require('playwright-core/lib/server/supplements/recorder/recorderApp');11const image = createImage();12console.log(image);13const { createImage } = require('playwright-core/lib/server/supplements/recorder/recorderApp');14const image = createImage();15console.log(image);16const { createImage } = require('playwright-core/lib/server/supplements/recorder/recorderApp');17const image = createImage();18console.log(image);19const { createImage } = require('playwright-core/lib/server/supplements/recorder/recorderApp');20const image = createImage();21console.log(image);22const { createImage } = require('playwright-core/lib/server/supplements/recorder/recorderApp');23const image = createImage();24console.log(image);25const { createImage } = require('playwright-core/lib/server/supplements/recorder/recorderApp');26const image = createImage();27console.log(image);28const { createImage } = require('playwright-core/lib/server/supplements/recorder/recorderApp');29const image = createImage();30console.log(image);
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!!