How to use iframe2 method in wpt

Best JavaScript code snippet using wpt

bbox.js

Source:bbox.js Github

copy

Full Screen

1/* eslint-env jasmine */2/* global loadPage:false */3/* eslint no-underscore-dangle: [2, {"allow": ["_id"]}] */4describe('BBox', function() {5 'use strict';6 var DOC_LEN = {7 'html-margin': 2,8 'html-border': 4,9 'html-padding': 8,10 'body-margin': 16,11 'body-border': 32,12 'body-padding': 64,13 'div-leftTop': 128,14 'iframe-border': 2,15 'iframe-padding': 4,16 'iframe1-left': 8,17 'iframe1-top': 316,18 'iframe2-left': 32,19 'iframe2-top': 764,20 'overflow-border': 2,21 'overflow-padding': 4,22 'overflow1-left': 308,23 'overflow1-top': 16,24 'overflow2-left': 132,25 'overflow2-top': 6426 },27 DIV_WIDTH = {static: 100, absolute: 101},28 DIV_HEIGHT = {static: 50, absolute: 51},29 SHOW_LOG = false;30 /* eslint-disable no-unused-vars, indent */31 // ================ context32 var33 SOCKET_TOP = 1, SOCKET_RIGHT = 2, SOCKET_BOTTOM = 3, SOCKET_LEFT = 4;34 function getSocketXY(bBox, socketId) {35 var socketXY = (36 socketId === SOCKET_TOP ? {x: bBox.left + bBox.width / 2, y: bBox.top} :37 socketId === SOCKET_RIGHT ? {x: bBox.right, y: bBox.top + bBox.height / 2} :38 socketId === SOCKET_BOTTOM ? {x: bBox.left + bBox.width / 2, y: bBox.bottom} :39 /* SOCKET_LEFT */ {x: bBox.left, y: bBox.top + bBox.height / 2});40 socketXY.socketId = socketId;41 return socketXY;42 }43 // ================ /context44 /* eslint-enable no-unused-vars, indent */45 function setUpDocument(props, document, body) {46 var targets = {html: document.documentElement, body: body || document.body};47 props.forEach(function(prop) {48 var targetProp = prop.split('-', 2),49 target = targets[targetProp[0]], propName = targetProp[1];50 if (propName === 'relative') {51 target.style.position = propName;52 } else {53 if (propName === 'border') { propName += 'Width'; }54 target.style[propName] = DOC_LEN[prop] + 'px';55 }56 });57 }58 // props: {{left, top, width, height}}59 function createBBox(props) {60 return {left: props.left, top: props.top, width: props.width, height: props.height,61 right: props.left + props.width, bottom: props.top + props.height};62 }63 describe('coordinates should be got when:', function() {64 [65 {66 props: ['html-margin', 'html-border', 'html-padding'],67 expected: {68 static: ['html-margin', 'html-border', 'html-padding'],69 absolute: ['div-leftTop']70 }71 },72 {73 props: ['body-margin', 'body-border', 'body-padding'],74 expected: {75 static: ['body-margin', 'body-border', 'body-padding'],76 absolute: ['div-leftTop']77 }78 },79 {80 props: ['html-padding', 'body-margin', 'body-border'],81 expected: {82 static: ['html-padding', 'body-margin', 'body-border'],83 absolute: ['div-leftTop']84 }85 },86 {87 props: ['html-margin', 'body-padding'],88 expected: {89 static: ['html-margin', 'body-padding'],90 absolute: ['div-leftTop']91 }92 },93 {94 props: ['html-margin', 'html-border', 'html-padding', 'body-margin', 'body-border', 'body-padding'],95 expected: {96 static: ['html-margin', 'html-border', 'html-padding', 'body-margin', 'body-border', 'body-padding'],97 absolute: ['div-leftTop']98 }99 },100 {101 props: [],102 expected: {103 static: [],104 absolute: ['div-leftTop']105 }106 },107 {108 props: ['html-border', 'body-margin', 'body-border', 'html-relative'],109 expected: {110 static: ['html-border', 'body-margin', 'body-border'],111 absolute: ['html-border', 'div-leftTop']112 }113 },114 {115 props: ['html-padding', 'body-margin', 'body-border', 'body-padding', 'body-relative'],116 expected: {117 static: ['html-padding', 'body-margin', 'body-border', 'body-padding'],118 absolute: ['html-padding', 'body-margin', 'body-border', 'div-leftTop']119 }120 }121 ].forEach(function(condition) {122 var title = 'enabled: ' + condition.props.join(', ');123 it(title, function(done) {124 loadPage('spec/bbox/coordinates.html', function(window, document, body) {125 var ll, props;126 setUpDocument(condition.props, document, body);127 ll = new window.LeaderLine(128 document.getElementById('static'),129 document.getElementById('absolute'),130 {endPlug: 'behind'}); // Make it have anchorBBoxSE[1]131 props = window.insProps[ll._id];132 ['static', 'absolute'].forEach(function(div, i) {133 var len = condition.expected[div].reduce(function(sum, prop) { return (sum += DOC_LEN[prop]); }, 0);134 expect(window.pathData2BBox(props.aplStats.capsMaskAnchor_pathDataSE[i]))135 .toEqual(createBBox({left: len, top: len, width: DIV_WIDTH[div], height: DIV_HEIGHT[div]}));136 });137 done();138 }, title);139 });140 });141 });142 describe('coordinates and `baseWindow` should be got with nested windows:', function() {143 /*144 #static, #absolute145 #iframe1146 #static, #absolute147 #iframe2148 #static, #absolute149 #iframe1150 #static, #absolute151 #iframe2152 #static, #absolute153 */154 [155 [':html-margin', ':html-border', ':html-padding', ':body-margin', ':body-border', ':body-padding',156 'iframe1:html-margin', 'iframe1:html-border', 'iframe1:html-padding',157 'iframe1:body-margin', 'iframe1:body-border', 'iframe1:body-padding',158 'iframe2:html-margin', 'iframe2:html-border', 'iframe2:html-padding',159 'iframe2:body-margin', 'iframe2:body-border', 'iframe2:body-padding',160 'iframe2_iframe1:html-margin', 'iframe2_iframe1:html-border', 'iframe2_iframe1:html-padding',161 'iframe2_iframe1:body-margin', 'iframe2_iframe1:body-border', 'iframe2_iframe1:body-padding',162 'iframe2_iframe2:html-margin', 'iframe2_iframe2:html-border', 'iframe2_iframe2:html-padding',163 'iframe2_iframe2:body-margin', 'iframe2_iframe2:body-border', 'iframe2_iframe2:body-padding'],164 [':body-margin', ':body-border', ':body-padding',165 'iframe1:body-margin', 'iframe1:body-border', 'iframe1:body-padding',166 'iframe2:body-margin', 'iframe2:body-border', 'iframe2:body-padding',167 'iframe2_iframe1:body-margin', 'iframe2_iframe1:body-border', 'iframe2_iframe1:body-padding',168 'iframe2_iframe2:body-margin', 'iframe2_iframe2:body-border', 'iframe2_iframe2:body-padding'],169 [':body-margin', ':body-border',170 'iframe1:body-margin', 'iframe1:body-border',171 'iframe2:body-margin', 'iframe2:body-border',172 'iframe2_iframe1:body-margin', 'iframe2_iframe1:body-border',173 'iframe2_iframe2:body-margin', 'iframe2_iframe2:body-border'],174 ['iframe1:body-margin', 'iframe1:body-border', 'iframe1:body-padding',175 'iframe2_iframe1:body-margin', 'iframe2_iframe1:body-border', 'iframe2_iframe1:body-padding',176 'iframe2_iframe2:body-margin', 'iframe2_iframe2:body-border', 'iframe2_iframe2:body-padding'],177 [],178 [':body-margin', ':body-border', ':body-padding', ':body-relative',179 'iframe1:body-margin', 'iframe1:body-border', 'iframe1:body-padding',180 'iframe2:body-margin', 'iframe2:body-border', 'iframe2:body-padding', 'iframe2:body-relative',181 'iframe2_iframe1:body-margin', 'iframe2_iframe1:body-border', 'iframe2_iframe1:body-padding',182 'iframe2_iframe2:body-margin', 'iframe2_iframe2:body-border', 'iframe2_iframe2:body-padding'],183 [':body-border', ':body-relative',184 'iframe1:body-border', 'iframe1:body-relative',185 'iframe2:body-border', 'iframe2:body-relative',186 'iframe2_iframe1:body-border', 'iframe2_iframe1:body-relative',187 'iframe2_iframe2:body-border', 'iframe2_iframe2:body-relative']188 ].forEach(function(condition) {189 var title = 'enabled: ' + condition.join(', ');190 it(title, function(done) {191 loadPage('spec/bbox/nested-window.html', function(window, document) {192 var elms = {}, docProps = {}, show = SHOW_LOG && !!document.title;193 if (show) { console.log('---- ' + title); }194 elms.static = document.getElementById('static');195 elms.absolute = document.getElementById('absolute');196 elms.iframe1Win = document.getElementById('iframe1').contentWindow;197 elms.iframe1 = document.getElementById('iframe1').contentDocument;198 elms.iframe2Win = document.getElementById('iframe2').contentWindow;199 elms.iframe2 = document.getElementById('iframe2').contentDocument;200 elms.iframe1_static = elms.iframe1.getElementById('static');201 elms.iframe1_absolute = elms.iframe1.getElementById('absolute');202 elms.iframe2_static = elms.iframe2.getElementById('static');203 elms.iframe2_absolute = elms.iframe2.getElementById('absolute');204 elms.iframe2_iframe1Win = elms.iframe2.getElementById('iframe1').contentWindow;205 elms.iframe2_iframe1 = elms.iframe2.getElementById('iframe1').contentDocument;206 elms.iframe2_iframe2Win = elms.iframe2.getElementById('iframe2').contentWindow;207 elms.iframe2_iframe2 = elms.iframe2.getElementById('iframe2').contentDocument;208 elms.iframe2_iframe1_static = elms.iframe2_iframe1.getElementById('static');209 elms.iframe2_iframe1_absolute = elms.iframe2_iframe1.getElementById('absolute');210 elms.iframe2_iframe2_static = elms.iframe2_iframe2.getElementById('static');211 elms.iframe2_iframe2_absolute = elms.iframe2_iframe2.getElementById('absolute');212 ['iframe1_static', 'iframe1_absolute', 'iframe2_static', 'iframe2_absolute',213 'iframe2_iframe1_static', 'iframe2_iframe1_absolute', 'iframe2_iframe2_static',214 'iframe2_iframe2_absolute'].forEach(function(key) {215 elms[key].textContent = key;216 });217 condition.forEach(function(prop) {218 var docTargetProp = prop.split(':', 2),219 doc = docTargetProp[0], targetProp = docTargetProp[1];220 (docProps[doc] = docProps[doc] || []).push(targetProp);221 });222 Object.keys(docProps).forEach(function(doc) {223 setUpDocument(docProps[doc], doc ? elms[doc] : document);224 });225 [226 {227 start: elms.iframe1_static,228 end: elms.iframe1_absolute,229 startDiv: 'static',230 endDiv: 'absolute',231 baseWindow: elms.iframe1Win,232 startWinPath: ['iframe1'],233 endWinPath: ['iframe1']234 },235 {236 start: elms.iframe2_iframe1_static,237 end: elms.iframe2_iframe2_absolute,238 startDiv: 'static',239 endDiv: 'absolute',240 baseWindow: elms.iframe2Win,241 startWinPath: ['iframe2', 'iframe2_iframe1'],242 endWinPath: ['iframe2', 'iframe2_iframe2']243 },244 {245 start: elms.iframe2_static,246 end: elms.iframe2_iframe2_absolute,247 startDiv: 'static',248 endDiv: 'absolute',249 baseWindow: elms.iframe2Win,250 startWinPath: ['iframe2'],251 endWinPath: ['iframe2', 'iframe2_iframe2']252 },253 {254 start: elms.iframe1_absolute,255 end: elms.iframe2_iframe2_absolute,256 startDiv: 'absolute',257 endDiv: 'absolute',258 baseWindow: window,259 startWinPath: ['', 'iframe1'],260 endWinPath: ['', 'iframe2', 'iframe2_iframe2']261 },262 {263 start: elms.static,264 end: elms.iframe2_iframe2_static,265 startDiv: 'static',266 endDiv: 'static',267 baseWindow: window,268 startWinPath: [''],269 endWinPath: ['', 'iframe2', 'iframe2_iframe2']270 },271 {272 start: elms.iframe1_absolute,273 end: elms.iframe2_absolute,274 startDiv: 'absolute',275 endDiv: 'absolute',276 baseWindow: window,277 startWinPath: ['', 'iframe1'],278 endWinPath: ['', 'iframe2']279 },280 {281 start: elms.iframe2_iframe2_static,282 end: elms.iframe2_iframe2_absolute,283 startDiv: 'static',284 endDiv: 'absolute',285 baseWindow: elms.iframe2_iframe2Win,286 startWinPath: ['iframe2_iframe2'],287 endWinPath: ['iframe2_iframe2']288 }289 ].forEach(function(item, iCase) {290 var ll = new window.LeaderLine(item.start, item.end, {endPlug: 'behind'}),291 props = window.insProps[ll._id];292 expect(props.baseWindow).toBe(item.baseWindow);293 ['start', 'end'].forEach(function(key, i) {294 function expandProps(frames, div) {295 var REL_HTML = ['html-margin', 'html-border'],296 REL_BODY = REL_HTML.concat(['html-padding', 'body-margin', 'body-border']),297 props = [];298 function addAbsolute(win) {299 if (condition.indexOf(win + ':body-relative') > -1) {300 props = props.concat(REL_BODY.map(function(prop) { return win + ':' + prop; }));301 } else if (condition.indexOf(win + ':html-relative') > -1) {302 props = props.concat(REL_HTML.map(function(prop) { return win + ':' + prop; }));303 }304 }305 frames.forEach(function(frame, i) {306 var names, name;307 if (i < frames.length - 1) { // iframe coordinates308 addAbsolute(frame);309 names = frames[i + 1].split('_');310 name = names[names.length - 1];311 props.push(':' + name + '-left', ':' + name + '-top', ':iframe-border', ':iframe-padding');312 } else { // div coordinates313 if (div === 'static') {314 props = props.concat(315 REL_BODY.concat(['body-padding']).map(function(prop) { return frame + ':' + prop; }));316 } else {317 addAbsolute(frame);318 props.push(':div-leftTop');319 }320 }321 });322 return props;323 }324 var bBox = createBBox(325 expandProps(item[key + 'WinPath'], item[key + 'Div'])326 .reduce(function(bBox, prop) {327 var targetProp = prop.split(':', 2)[1],328 leftTop = (/\-(left|top)$/.exec(targetProp) || [])[1];329 if (condition.indexOf(prop) > -1 ||330 leftTop || targetProp === 'iframe-border' || targetProp === 'iframe-padding' ||331 targetProp === 'div-leftTop') {332 if (!leftTop || leftTop === 'left') { bBox.left += DOC_LEN[targetProp]; }333 if (!leftTop || leftTop === 'top') { bBox.top += DOC_LEN[targetProp]; }334 }335 return bBox;336 },337 {left: 0, top: 0,338 width: DIV_WIDTH[item[key + 'Div']], height: DIV_HEIGHT[item[key + 'Div']]})),339 expected = window.pathData2BBox(props.aplStats.capsMaskAnchor_pathDataSE[i]);340 expected.index = bBox.index = iCase; // for error information341 expected.key = bBox.key = key; // for error information342 expect(expected).toEqual(bBox);343 expect(props.aplStats.position_socketXYSE[i])344 .toEqual(getSocketXY(bBox, props.aplStats.position_socketXYSE[i].socketId));345 });346 if (show) {347 console.log('---- start:');348 console.log(item.start);349 console.log('---- end:');350 console.log(item.end);351 console.log('---- document:');352 console.log(item.baseWindow.document);353 console.log('---- svg:');354 console.log(props.svg);355 console.log('---- path:');356 console.log(props.path);357 }358 });359 done();360 }, title);361 });362 });363 });364 describe('coordinates with scroll', function() {365 /*366 #static367 #overflow1368 #overflow1-static369 #overflow2370 #overflow2-absolute371 #iframe1372 #static373 #overflow1374 #overflow1-static375 #overflow2376 #overflow2-absolute377 */378 var scrollLen = 10,379 condition = [':body-border', ':body-padding', ':body-relative', 'iframe1:html-border', 'iframe1:html-padding'];380 [condition, condition.concat('scroll')].forEach(function(condition) {381 var scroll = condition.indexOf('scroll') > -1 ? scrollLen : 0,382 title = 'scroll: ' + scroll;383 it(title, function(done) {384 loadPage('spec/bbox/scroll.html', function(window, document) {385 var elms = {};386 elms.static = document.getElementById('static');387 elms.overflow1 = document.getElementById('overflow1');388 elms.overflow1_static = document.getElementById('overflow1-static');389 elms.overflow1_overflow2 = document.getElementById('overflow2');390 elms.overflow1_overflow2_absolute = document.getElementById('overflow2-absolute');391 elms.iframe1Win = document.getElementById('iframe1').contentWindow;392 elms.iframe1 = document.getElementById('iframe1').contentDocument;393 elms.iframe1_static = elms.iframe1.getElementById('static');394 elms.iframe1_overflow1 = elms.iframe1.getElementById('overflow1');395 elms.iframe1_overflow1_static = elms.iframe1.getElementById('overflow1-static');396 elms.iframe1_overflow1_overflow2 = elms.iframe1.getElementById('overflow2');397 elms.iframe1_overflow1_overflow2_absolute = elms.iframe1.getElementById('overflow2-absolute');398 if (scroll) {399 window.scroll(scroll, scroll);400 elms.iframe1Win.scroll(scroll, scroll);401 ['overflow1', 'overflow1_overflow2', 'iframe1_overflow1', 'iframe1_overflow1_overflow2']402 .forEach(function(overflow) { elms[overflow].scrollLeft = elms[overflow].scrollTop = scroll; });403 }404 [405 {406 start: elms.static,407 end: elms.overflow1_static,408 startDiv: 'static',409 endDiv: 'static',410 baseWindow: window,411 startWinPath: [''],412 endWinPath: ['', 'overflow1']413 },414 {415 start: elms.static,416 end: elms.overflow1_overflow2_absolute,417 startDiv: 'static',418 endDiv: 'absolute',419 baseWindow: window,420 startWinPath: [''],421 endWinPath: ['', 'overflow1', 'overflow1_overflow2']422 },423 {424 start: elms.static,425 end: elms.iframe1_static,426 startDiv: 'static',427 endDiv: 'static',428 baseWindow: window,429 startWinPath: [''],430 endWinPath: ['', 'iframe1']431 },432 {433 start: elms.static,434 end: elms.iframe1_overflow1_static,435 startDiv: 'static',436 endDiv: 'static',437 baseWindow: window,438 startWinPath: [''],439 endWinPath: ['', 'iframe1', 'iframe1_overflow1']440 },441 {442 start: elms.static,443 end: elms.iframe1_overflow1_overflow2_absolute,444 startDiv: 'static',445 endDiv: 'absolute',446 baseWindow: window,447 startWinPath: [''],448 endWinPath: ['', 'iframe1', 'iframe1_overflow1', 'iframe1_overflow1_overflow2']449 },450 {451 start: elms.iframe1_static,452 end: elms.iframe1_overflow1_static,453 startDiv: 'static',454 endDiv: 'static',455 baseWindow: elms.iframe1Win,456 startWinPath: ['iframe1'],457 endWinPath: ['iframe1', 'iframe1_overflow1']458 },459 {460 start: elms.iframe1_static,461 end: elms.iframe1_overflow1_overflow2_absolute,462 startDiv: 'static',463 endDiv: 'absolute',464 baseWindow: elms.iframe1Win,465 startWinPath: ['iframe1'],466 endWinPath: ['iframe1', 'iframe1_overflow1', 'iframe1_overflow1_overflow2']467 }468 ].forEach(function(item, iCase) {469 var ll = new window.LeaderLine(item.start, item.end, {endPlug: 'behind'}),470 props = window.insProps[ll._id];471 expect(props.baseWindow).toBe(item.baseWindow);472 ['start', 'end'].forEach(function(key, i) {473 function expandProps(frames, div) {474 var REL_HTML = ['html-margin', 'html-border'],475 REL_BODY = REL_HTML.concat(['html-padding', 'body-margin', 'body-border']),476 props = [];477 function addAbsolute(win) {478 if (condition.indexOf(win + ':body-relative') > -1) {479 props = props.concat(REL_BODY.map(function(prop) { return win + ':' + prop; }));480 } else if (condition.indexOf(win + ':html-relative') > -1) {481 props = props.concat(REL_HTML.map(function(prop) { return win + ':' + prop; }));482 }483 }484 frames.forEach(function(frame, i) {485 var names, name, frmClass;486 if (i < frames.length - 1) { // iframe coordinates487 if (!/(?:^|_)overflow/.test(frame)) { addAbsolute(frame); }488 names = frames[i + 1].split('_');489 name = names[names.length - 1];490 frmClass = (/^(.+?)\d*$/.exec(name) || [])[1];491 props.push(':' + name + '-left', ':' + name + '-top', ':' + frmClass + '-border');492 if (frmClass !== 'overflow') { props.push(':' + frmClass + '-padding'); }493 } else { // div coordinates494 names = frame.split('_');495 name = names[names.length - 1];496 frmClass = (/^(.+?)\d?$/.exec(name) || [])[1];497 if (frmClass !== 'overflow') {498 if (div === 'static') {499 props = props.concat(500 REL_BODY.concat(['body-padding']).map(function(prop) { return frame + ':' + prop; }));501 } else {502 addAbsolute(frame);503 props.push(':div-leftTop');504 }505 } else {506 if (div === 'static') {507 props.push(':' + frmClass + '-padding');508 } else {509 props.push(':div-leftTop');510 }511 }512 }513 if (scroll && i > 0 &&514 (!frame || /iframe\d*$/.test(frame) || /overflow\d*$/.test(frame))) {515 props.push(':scroll');516 }517 });518 return props;519 }520 var bBox = createBBox(521 expandProps(item[key + 'WinPath'], item[key + 'Div'])522 .reduce(function(bBox, prop) {523 var targetProp = prop.split(':', 2)[1],524 leftTop = (/\-(left|top)$/.exec(targetProp) || [])[1];525 if (targetProp === 'scroll') {526 bBox.left -= scroll;527 bBox.top -= scroll;528 } else if (condition.indexOf(prop) > -1 ||529 leftTop ||530 targetProp === 'iframe-border' || targetProp === 'iframe-padding' ||531 targetProp === 'overflow-border' || targetProp === 'overflow-padding' ||532 targetProp === 'div-leftTop') {533 if (!leftTop || leftTop === 'left') { bBox.left += DOC_LEN[targetProp]; }534 if (!leftTop || leftTop === 'top') { bBox.top += DOC_LEN[targetProp]; }535 }536 return bBox;537 },538 {left: 0, top: 0,539 width: DIV_WIDTH[item[key + 'Div']], height: DIV_HEIGHT[item[key + 'Div']]})),540 expected = window.pathData2BBox(props.aplStats.capsMaskAnchor_pathDataSE[i]);541 expected.index = bBox.index = iCase; // for error information542 expected.key = bBox.key = key; // for error information543 expect(expected).toEqual(bBox);544 expect(props.aplStats.position_socketXYSE[i])545 .toEqual(getSocketXY(bBox, props.aplStats.position_socketXYSE[i].socketId));546 });547 });548 done();549 }, title);550 });551 });552 });553 describe('SVG anchor', function() {554 it('bBox works as same as HTMLElement', function(done) {555 loadPage('spec/common/page.html', function(window, document) {556 var ll = new window.LeaderLine(557 document.getElementById('elm1'),558 document.getElementById('rect1')),559 aplStats = window.insProps[ll._id].aplStats,560 bBox = document.getElementById('rect1').getBoundingClientRect(),561 TOLERANCE = window.IS_TRIDENT ? 3 : 0.1;562 // {x: 205, y: 216, width: 20, height: 20}563 expect(bBox.left - 205).toBeLessThan(TOLERANCE);564 expect(bBox.top - 216).toBeLessThan(TOLERANCE);565 expect(bBox.width - 20).toBeLessThan(TOLERANCE);566 expect(bBox.height - 20).toBeLessThan(TOLERANCE);567 expect(bBox.right - (205 + 20)).toBeLessThan(TOLERANCE);568 expect(bBox.bottom - (216 + 20)).toBeLessThan(TOLERANCE);569 ll.endSocket = 'top';570 expect(aplStats.position_socketXYSE[1].x).toBe(bBox.left + bBox.width / 2);571 expect(aplStats.position_socketXYSE[1].y).toBe(bBox.top);572 ll.endSocket = 'right';573 expect(aplStats.position_socketXYSE[1].x).toBe(bBox.right);574 expect(aplStats.position_socketXYSE[1].y).toBe(bBox.top + bBox.height / 2);575 ll.endSocket = 'bottom';576 expect(aplStats.position_socketXYSE[1].x).toBe(bBox.left + bBox.width / 2);577 expect(aplStats.position_socketXYSE[1].y).toBe(bBox.bottom);578 ll.endSocket = 'left';579 expect(aplStats.position_socketXYSE[1].x).toBe(bBox.left);580 expect(aplStats.position_socketXYSE[1].y).toBe(bBox.top + bBox.height / 2);581 done();582 }, 'SVG');583 });584 });...

Full Screen

Full Screen

booklet.js

Source:booklet.js Github

copy

Full Screen

1javascript: void((function(){2// Get placard html3var iframeplacard = null;4if ( document.querySelector('.ta-tableContainer') ) {5 iframeplacard = document.querySelector('.ta-tableContainer');6 iframeplacard = iframeplacard.outerHTML;7}8// Get Bet365 html9var iframe = document.querySelector('#MembersHostFrame');10iframe = iframe.contentWindow.document;11iframe = iframe.querySelector('.historyV3Iframe');12iframe = iframe.contentWindow.document;13iframe = iframe.querySelector('.bet-confirmation-viewer');14var html = iframe.outerHTML;15var iframe2 = document.querySelector('#MembersHostFrame');16iframe2 = iframe2.contentWindow.document;17iframe2 = iframe2.querySelector('.historyV3Iframe');18iframe2 = iframe2.contentWindow.document;19iframe2 = iframe2.querySelector('.bet-breakdown-table');20var html2 = iframe2.outerHTML;21result = html + html2 + iframeplacard;22// Copy content in result23var node = document.createElement('textarea');24var selection = document.getSelection();25node.textContent = result;26document.body.appendChild(node);27selection.removeAllRanges();28node.select();29document.execCommand('copy');30selection.removeAllRanges();31document.body.removeChild(node);32console.log(result);33console.log("end");34window.open('https://home.camacho.pt/labs/bet-parser/', '_blank');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var location = 'ec2-us-west-1:Chrome';4var runs = 1;5var firstViewOnly = true;6var pollResults = 5;7var timeout = 300;8var video = true;

Full Screen

Using AI Code Generation

copy

Full Screen

1function test() {2 var wpt = new WebPageTest('www.webpagetest.org');3 }, function (err, data) {4 if (err) {5 console.log('Error: ' + err);6 } else {7 console.log('Test status: ' + data.statusCode);8 console.log('Test ID: ' + data.data.testId);9 console.log('Test URL: ' + data.data.summary);10 }11 });12}13function test() {14 var wpt = new WebPageTest('www.webpagetest.org');15 lighthouseConfig: {16 "settings": {17 }18 },19 mobileDeviceUA: "Mozilla/5.0 (Linux; Android 6.0.1; Moto G (4) Build/MPJ24.139-64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.158 Mobile Safari/537.36",

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var api = new wpt('www.webpagetest.org');3var options = {4};5api.runTest(options, function(err, data) {6 if (err) return console.error(err);7 console.log(data);8});9### new WebPageTest(server[, options])10### webpagetest.runTest(options, callback)

Full Screen

Using AI Code Generation

copy

Full Screen

1let iframe2 = new Wptb.Iframe2({2 container: document.getElementById('iframe2-container')3});4iframe2.on('load', () => {5 console.log('iframe2 loaded');6 iframe2.sendMessage('hello from iframe2');7});8iframe2.on('message', (message) => {9 console.log('iframe2 received message: ', message);10});11let iframe = new Wptb.Iframe({12 container: document.getElementById('iframe-container')13});14iframe.on('load', () => {15 console.log('iframe loaded');16 iframe.sendMessage('hello from iframe');17});18iframe.on('message', (message) => {19 console.log('iframe received message: ', message);20});21let iframe3 = new Wptb.Iframe({22 container: document.getElementById('iframe3-container')23});24iframe3.on('load', () => {25 console.log('iframe3 loaded');26 iframe3.sendMessage('hello from iframe3');27});28iframe3.on('message', (message) => {29 console.log('iframe3 received message: ', message);30});31let iframe4 = new Wptb.Iframe({32 container: document.getElementById('iframe4-container')33});34iframe4.on('load', () => {35 console.log('iframe4 loaded');36 iframe4.sendMessage('hello from iframe4');37});38iframe4.on('message', (message) => {39 console.log('iframe4 received message: ', message);40});41let iframe5 = new Wptb.Iframe({42 container: document.getElementById('iframe5-container')43});44iframe5.on('load', () => {45 console.log('iframe5 loaded');46 iframe5.sendMessage('hello from iframe5');47});48iframe5.on('message', (message) => {49 console.log('iframe5 received message: ', message);50});51let iframe6 = new Wptb.Iframe({

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./lib/webpagetest.js');2var wpt = new wpt('www.webpagetest.org','A.9e1f9d9e8c8b0e6f2b2b2c2b2b2b2b2b');3var location = 'Dulles:Chrome';4var runs = 1;5var firstViewOnly = false;6wpt.runTest(url, location, runs, firstViewOnly, function(err, data) {7 if (err) {8 console.log(err);9 } else {10 wpt.getTestResults(data.data.testId, function(err, data) {11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16 });17 }18});19var wpt = require('./lib/webpagetest.js');20var wpt = new wpt('www.webpagetest.org','A.9e1f9d9e8c8b0e6f2b2b2c2b2b2b2b2b');21var location = 'Dulles:Chrome';22var runs = 1;23var firstViewOnly = false;24wpt.runTest(url, location, runs, firstViewOnly, function(err, data) {25 if (err) {26 console.log(err);27 } else {28 wpt.getTestResults(data.data.testId, function(err, data) {29 if (err) {30 console.log(err);31 } else {32 console.log(data);33 }34 });35 }36});37var wpt = require('./lib/webpagetest.js');38var wpt = new wpt('www.webpagetest.org','A.9e1f9d9e8c8b0e6f2b2b2c2b2b2b2b2b');

Full Screen

Automation Testing Tutorials

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

LambdaTest Learning Hubs:

YouTube

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

Run wpt automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful