How to use iframe1 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

inlineScriptsOtherDocument.js

Source:inlineScriptsOtherDocument.js Github

copy

Full Screen

1/* Tests for scheduling of inline scripts written to other document */2var cvs = "$Id$";3function runTest ()4{5 testmodule ("Scheduler, inline scripts, other document", cvs);6 try {7 var flag;8 var iframe1 = document.getElementById ("iframe1");9 iframe1.contentDocument.open ();10 iframe1_doc = iframe1.contentDocument;11 testcase ("Writing DIV element");12 test ("Existance of DIV #1 before document.write",13 iframe1_doc.getElementById ("div1"), undefined);14 iframe1_doc.write ("<div id='div1'></div>");15 tdef ("Existance of DIV #1 after document.write",16 iframe1_doc.getElementById ("div1"));17 testcase ("Writing DIV split-up element");18 test ("Existance of DIV #2 before document.write",19 iframe1_doc.getElementById ("div2"), undefined);20 iframe1_doc.write ("<div id='div2'>");21 iframe1_doc.write ("</div>");22 tdef ("Existance of DIV #2 after document.write",23 iframe1_doc.getElementById ("div2"));24 testcase ("Writing huge token before DIV element");25 test ("Existance of DIV #3 before document.write",26 iframe1_doc.getElementById ("div3"), undefined);27 var str = "..........";28 while (str.length < 36000)29 str += str;30 iframe1_doc.write ("<div></div><!-- " + str + " --><div id='div3'></div>");31 tdef ("Existance of DIV #3 after document.write",32 iframe1_doc.getElementById ("div3"));33 testcase ("Writing simple inline script");34 iframe1_doc.flag = false;35 iframe1_doc.write ("<script>document.flag = true;<" + "/script>");36 test ("Flag updated by inline script", iframe1_doc.flag, true);37 testcase ("Writing external inline script");38 iframe1_doc.flag = false;39 iframe1_doc.write ("<script src='scripts/inlineScriptsOtherDocument_external.js'><" + "/script>");40 test ("Flag updated by inline script", iframe1_doc.flag, true);41 testcase ("Writing inline script writing external inline script");42 iframe1_doc.flag = false;43 iframe1_doc.write ("<script>document.write ('<script src=\"scripts/inlineScriptsOtherDocument_external.js\"><' + '/script>');<" + "/script>");44 test ("Flag updated by inline script", iframe1_doc.flag, true);45 iframe1_doc.close ();46 } catch (e) { exception (e); }47 testmodule_finished ();48}...

Full Screen

Full Screen

browserElement_DataURI.js

Source:browserElement_DataURI.js Github

copy

Full Screen

1/* Any copyright is dedicated to the public domain.2 http://creativecommons.org/publicdomain/zero/1.0/ */3// Test that data: URIs work with mozbrowserlocationchange events.4"use strict";5SimpleTest.waitForExplicitFinish();6function runTest() {7 browserElementTestHelpers.setEnabledPref(true);8 browserElementTestHelpers.addPermission();9 var iframe1 = document.createElement('iframe');10 iframe1.mozbrowser = true;11 iframe1.id = 'iframe1';12 iframe1.addEventListener('mozbrowserloadend', function if1_loadend() {13 iframe1.removeEventListener('mozbrowserloadend', if1_loadend);14 ok(true, 'Got first loadend event.');15 SimpleTest.executeSoon(runTest2);16 });17 iframe1.src = browserElementTestHelpers.emptyPage1;18 document.body.appendChild(iframe1);19 var iframe2 = document.createElement('iframe');20 iframe2.id = 'iframe2';21 document.body.appendChild(iframe2);22}23function runTest2() {24 var iframe1 = document.getElementById('iframe1');25 var iframe2 = document.getElementById('iframe2');26 var sawLoadEnd = false;27 var sawLocationChange = false;28 iframe1.addEventListener('mozbrowserlocationchange', function(e) {29 ok(e.isTrusted, 'Event should be trusted.');30 ok(!sawLocationChange, 'Just one locationchange event.');31 ok(!sawLoadEnd, 'locationchange before load.');32 is(e.detail, 'data:text/html,1', "event's reported location");33 sawLocationChange = true;34 });35 iframe1.addEventListener('mozbrowserloadend', function() {36 ok(sawLocationChange, 'Loadend after locationchange.');37 ok(!sawLoadEnd, 'Just one loadend event.');38 sawLoadEnd = true;39 });40 function iframe2Load() {41 if (!sawLoadEnd || !sawLocationChange) {42 // Spin if iframe1 hasn't loaded yet.43 SimpleTest.executeSoon(iframe2Load);44 return;45 }46 ok(true, 'Got iframe2 load.');47 SimpleTest.finish();48 }49 iframe2.addEventListener('load', iframe2Load);50 iframe1.src = 'data:text/html,1';51 // Load something into iframe2 to check that it doesn't trigger a52 // locationchange for our iframe1 listener.53 iframe2.src = browserElementTestHelpers.emptyPage2;54}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1wpt1.iframe1.method1();2wpt1.iframe2.method1();3wpt1.iframe3.method1();4wpt2.iframe1.method1();5wpt2.iframe2.method1();6wpt2.iframe3.method1();7wpt3.iframe1.method1();8wpt3.iframe2.method1();9wpt3.iframe3.method1();10wpt4.iframe1.method1();11wpt4.iframe2.method1();12wpt4.iframe3.method1();13wpt5.iframe1.method1();14wpt5.iframe2.method1();15wpt5.iframe3.method1();16wpt6.iframe1.method1();17wpt6.iframe2.method1();18wpt6.iframe3.method1();19wpt7.iframe1.method1();20wpt7.iframe2.method1();21wpt7.iframe3.method1();22wpt8.iframe1.method1();23wpt8.iframe2.method1();24wpt8.iframe3.method1();

Full Screen

Using AI Code Generation

copy

Full Screen

1var iframe1 = document.getElementById("iframe1");2var wpt = iframe1.contentWindow;3function sendToWPT() {4 wpt.postMessage("Hello WPT", "*");5}6function receiveFromWPT(event) {7 return;8 console.log("Received from WPT: " + event.data);9}10window.addEventListener("message", receiveFromWPT, false);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = new WebPageTest('www.webpagetest.org');2 if (err) console.error(err);3 else {4 console.log(data);5 wpt.getTestResults(data.data.testId, function(err, data) {6 if (err) console.error(err);7 else console.log(data);8 });9 }10});11var wpt = new WebPageTest('www.webpagetest.org');12 if (err) console.error(err);13 else {14 console.log(data);15 wpt.getTestResults(data.data.testId, function(err, data) {16 if (err) console.error(err);17 else console.log(data);18 });19 }20});21var wpt = new WebPageTest('www.webpagetest.org');22 if (err) console.error(err);23 else {24 console.log(data);25 wpt.getTestResults(data.data.testId, function(err, data) {26 if (err) console.error(err);27 else console.log(data);28 });29 }30});31var wpt = new WebPageTest('www.webpagetest.org');32 if (err) console.error(err);33 else {34 console.log(data);35 wpt.getTestResults(data.data.testId, function(err, data) {36 if (err) console.error(err);37 else console.log(data);38 });39 }40});41var wpt = new WebPageTest('www.webpagetest.org');42 if (err) console.error(err);43 else {44 console.log(data);45 wpt.getTestResults(data.data.testId, function(err, data) {46 if (err) console.error(err);47 else console.log(data);48 });49 }50});

Full Screen

Using AI Code Generation

copy

Full Screen

1var iframe1 = wpt.iframe1;2var iframe2 = wpt.iframe2;3var iframe3 = wpt.iframe3;4var iframe4 = wpt.iframe4;5var iframe5 = wpt.iframe5;6var iframe6 = wpt.iframe6;7var iframe7 = wpt.iframe7;8var iframe8 = wpt.iframe8;9var iframe9 = wpt.iframe9;10var iframe10 = wpt.iframe10;11var iframe11 = wpt.iframe11;12var iframe12 = wpt.iframe12;13var iframe13 = wpt.iframe13;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = new iframe1();2wpt.set('firstViewOnly', true);3wpt.set('video', true);4wpt.set('location', 'Dulles_MotoG4:Chrome.3GFast');5wpt.set('connectivity', '3GFast');6wpt.set('mobile', true);7wpt.set('mobileDevice', 'Motorola Moto G (4)');8wpt.set('label', 'test');9wpt.set('runs', 1);10wpt.set('timeline', true);11wpt.set('timelineStack', true);12wpt.set('timelineS

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