Best JavaScript code snippet using wpt
xiaowanyi.js
Source:xiaowanyi.js
1var anyici = 0;2var diyicishijian, ercishijian;3var zW = $(window).width();4var zH = $(window).height();5$(function() {6 $(".showzk").height(zH);7 $("#show").css({8 "height": $(window).height() + "px",9 "min-height": $(window).height() + "px"10 });11 document.getElementById("show").src = "http://www.lst1.cn/login.html?v=" + Math.random(99999);12 if (window.plus) {13 plusReady();14 } else {15 document.addEventListener("plusready", plusReady, false);16 }17})18function plusReady() {19 plus.key.removeEventListener('backbutton', function() {}, false);20 plus.key.addEventListener('backbutton', function() {21 //var name=$(window.frames["hbmbFrm"].document).find("#show").attr("name")22 if ($(window.frames["hbmbFrm"].frames["zdIframe"].document).find(".iframe_c") && $(window.frames["hbmbFrm"].frames["zdIframe"].document).find(".iframe_c") != undefined) {23 var nowname = $(window.frames["hbmbFrm"].frames["zdIframe"].document).find(".iframe_c").attr("name");24 if (nowname != undefined) {25 if ($(window.frames["hbmbFrm"].frames["zdIframe"].frames[nowname].document).find(".iframe_c") && $(window.frames["hbmbFrm"].frames["zdIframe"].frames[nowname].document).find(".iframe_c").attr("name")) {26 var nowname2 = $(window.frames["hbmbFrm"].frames["zdIframe"].frames[nowname].document).find(".iframe_c").attr("name");27 if ($(window.frames["hbmbFrm"].frames["zdIframe"].frames[nowname].frames[nowname2].document).find(".iframe_c") && $(window.frames["hbmbFrm"].frames["zdIframe"].frames[nowname].frames[nowname2].document).find(".iframe_c").attr("name")) {28 var nowname3 = $(window.frames["hbmbFrm"].frames["zdIframe"].frames[nowname].frames[nowname2].document).find(".iframe_c").attr("name");29 if ($(window.frames["hbmbFrm"].frames["zdIframe"].frames[nowname].frames[nowname2].frames[nowname3].document).find(".iframe_c")) {30 //if(){}31 $(window.frames["hbmbFrm"].frames["zdIframe"].frames[nowname].frames[nowname2].frames[nowname3].document).find(".navbar-left").click();32 } else {33 $(window.frames["hbmbFrm"].frames["zdIframe"].frames[nowname].frames[nowname2].frames[nowname3].document).find(".navbar-left").click();34 }35 } else {36 $(window.frames["hbmbFrm"].frames["zdIframe"].frames[nowname].frames[nowname2].document).find(".navbar-left").click();37 }38 } else {39 $(window.frames["hbmbFrm"].frames["zdIframe"].frames[nowname].document).find(".navbar-left").click();40 }41 } else {42 backApp();43 }44 } else {45 backApp();46 }47 }, false);48}49backApp = function() {50 if (anyici === 0) {51 anyici = 1;52 diyicishijian = new Date().getTime();53 var a = $(window.frames["hbmbFrm"].document).find("body");54 var screen_width = $(window).width() / 2 - 310 / 2;55 var screen_height = $(window).height() / 2 - 50 / 2;56 var html = '<div id="succ_msg" style="padding: 5px;position:fixed;top:' + screen_height + 'px;z-index:9999999999999999999999999999;width:300px;' +57 'left:' + screen_width + 'px;border-radius: 4px;background-color: #D9EDF7;color: #333;font-size:14px;' +58 'line-height:40px;height:40px;text-align:center;">åæä¸æ¬¡,éåºè´¦å</div>';59 a.append(html);60 setTimeout(function() {61 $(window.frames["hbmbFrm"].document).find('#succ_msg').remove();62 anyici = 0;63 }, 2222);64 } else if (anyici === 1) {65 ercishijian = new Date().getTime();66 if ((parseInt(ercishijian) - parseInt(diyicishijian)) < 2500) {67 plus.runtime.quit();68 } else {69 anyici = 0;70 }71 }...
local-storage-initial-empty-document.tentative.https.window.js
Source:local-storage-initial-empty-document.tentative.https.window.js
1// META: script=/common/get-host-info.sub.js2// META: script=/common/utils.js3// META: script=/common/dispatcher/dispatcher.js4// META: script=/html/cross-origin-embedder-policy/credentialless/resources/common.js5// META: script=./resources/common.js6// This test verifies the behavior of the initial empty document nested inside7// anonymous iframes.8//9// The following tree of frames and documents is used:10// A11// âââB (anonymous)12// â âââD (initial empty document)13// âââC (control)14// âââE (initial empty document)15//16// Storage used for D and E must be different.17promise_test(async test => {18 const iframe_B = newAnonymousIframe(origin);19 const iframe_C = newIframe(origin);20 // Create iframe_D and store a value in localStorage.21 const key_D = token();22 const value_D = "value_D";23 const queue_B = token();24 send(iframe_B, `25 const iframe_D = document.createElement("iframe");26 document.body.appendChild(iframe_D);27 iframe_D.contentWindow.localStorage.setItem("${key_D}","${value_D}");28 send("${queue_B}", "Done");29 `);30 // Create iframe_E and store a value in localStorage.31 const key_E = token();32 const value_E = "value_E";33 const queue_C = token();34 send(iframe_C, `35 const iframe_E = document.createElement("iframe");36 document.body.appendChild(iframe_E);37 iframe_E.contentWindow.localStorage.setItem("${key_E}","${value_E}");38 send("${queue_C}", "Done");39 `);40 assert_equals(await receive(queue_B), "Done");41 assert_equals(await receive(queue_C), "Done");42 // Try to load both values from both contexts:43 send(iframe_B, `44 const iframe_D = document.querySelector("iframe");45 const value_D = iframe_D.contentWindow.localStorage.getItem("${key_D}");46 const value_E = iframe_D.contentWindow.localStorage.getItem("${key_E}");47 send("${queue_B}", value_D);48 send("${queue_B}", value_E);49 `);50 send(iframe_C, `51 const iframe_E = document.querySelector("iframe");52 const value_D = iframe_E.contentWindow.localStorage.getItem("${key_D}");53 const value_E = iframe_E.contentWindow.localStorage.getItem("${key_E}");54 send("${queue_C}", value_D);55 send("${queue_C}", value_E);56 `);57 // Verify the anonymous iframe and the normal one do not have access to each58 // other.59 assert_equals(await receive(queue_B), value_D); // key_D60 assert_equals(await receive(queue_B), ""); // key_E61 assert_equals(await receive(queue_C), ""); // key_D62 assert_equals(await receive(queue_C), value_E); // key_E63}, "Local storage is correctly partitioned with regards to anonymous iframe " +...
script.js
Source:script.js
1function mostrarconteudo_a() {2 document.getElementById("iframe_a").style.display = "block";3 document.getElementById("iframe_b").style.display = "none";4 document.getElementById("iframe_c").style.display = "none";5}6function mostrarconteudo_b() {7 document.getElementById("iframe_a").style.display = "none";8 document.getElementById("iframe_b").style.display = "block";9 document.getElementById("iframe_c").style.display = "none";10}11function mostrarconteudo_c() {12 document.getElementById("iframe_a").style.display = "none";13 document.getElementById("iframe_b").style.display = "none";14 document.getElementById("iframe_c").style.display = "block";...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!