How to use pc2 method in wpt

Best JavaScript code snippet using wpt

basic.js

Source:basic.js Github

copy

Full Screen

1/* testing basic session establishment */2var test = require('tape');3var PeerConnection = require('../rtcpeerconnection');4var adapter = require('webrtc-adapter'); // jshint ignore:line5test('basic connection establishment', function (t) {6 var pc1, pc2;7 var ended = false;8 pc1 = new PeerConnection();9 pc2 = new PeerConnection();10 pc1.on('ice', function (candidate) {11 //console.log('pc1 candidate', candidate);12 pc2.processIce(candidate);13 });14 pc2.on('ice', function (candidate) {15 //console.log('pc2 candidate', candidate);16 pc1.processIce(candidate);17 });18 pc1.on('iceConnectionStateChange', function () {19 //console.log('pc1 iceConnectionStateChange', pc1.iceConnectionState);20 if (pc1.iceConnectionState === 'connected' ||21 pc1.iceConnectionState === 'completed') {22 if (!ended) {23 t.pass('P2P connection established');24 ended = true;25 t.end();26 }27 }28 // FIXME: also look for https://code.google.com/p/webrtc/issues/detail?id=141429 });30 pc2.on('iceConnectionStateChange', function () {31 //console.log('pc2 iceConnectionStateChange', pc2.iceConnectionState);32 });33 navigator.mediaDevices.getUserMedia({video: true, fake: true})34 .then(function (stream) {35 pc1.addStream(stream);36 pc1.offer(function (err, offer) {37 if (err) {38 t.fail('failed to create offer');39 return;40 }41 t.pass('created offer');42 pc2.handleOffer(offer, function (err) {43 if (err) {44 // handle error45 t.fail('error handling offer');46 return;47 }48 t.pass('handled offer');49 pc2.answer(function (err, answer) {50 if (err) {51 t.fail('error handling answer');52 return;53 }54 t.pass('created answer');55 pc1.handleAnswer(answer, function (err) {56 if (err) {57 t.fail('failed to handle answer');58 return;59 }60 t.pass('handled answer');61 });62 });63 });64 });65 })66 .catch(function (err) {67 t.fail(err);68 });69});70test('basic connection establishment -- using Jingle', function (t) {71 var pc1, pc2;72 var ended = false;73 pc1 = new PeerConnection({useJingle: true});74 pc2 = new PeerConnection({useJingle: true});75 pc1.on('ice', function (candidate) {76 pc2.processIce(candidate);77 });78 pc2.on('ice', function (candidate) {79 pc1.processIce(candidate);80 });81 pc1.on('iceConnectionStateChange', function () {82 //console.log('pc1 iceConnectionStateChange', pc1.iceConnectionState);83 if (pc1.iceConnectionState === 'connected' ||84 pc1.iceConnectionState === 'completed') {85 if (!ended) {86 t.pass('P2P connection established');87 ended = true;88 t.end();89 }90 }91 // FIXME: also look for https://code.google.com/p/webrtc/issues/detail?id=141492 });93 pc2.on('iceConnectionStateChange', function () {94 //console.log('pc2 iceConnectionStateChange', pc2.iceConnectionState);95 });96 navigator.mediaDevices.getUserMedia({video: true, fake: true})97 .then(function (stream) {98 pc1.addStream(stream);99 pc1.offer(function (err, offer) {100 if (err) {101 t.fail('failed to create offer');102 return;103 }104 t.pass('created offer');105 pc2.handleOffer(offer, function (err) {106 if (err) {107 // handle error108 t.fail('error handling offer');109 return;110 }111 t.pass('handled offer');112 pc2.answer(function (err, answer) {113 if (err) {114 t.fail('error handling answer');115 return;116 }117 t.pass('created answer');118 pc1.handleAnswer(answer, function (err) {119 if (err) {120 t.fail('failed to handle answer');121 return;122 }123 t.pass('handled answer');124 });125 });126 });127 });128 });129});130test('async accept', function (t) {131 var pc1, pc2;132 var ended = false;133 pc1 = new PeerConnection({useJingle: true});134 pc2 = new PeerConnection({useJingle: true});135 pc1.on('ice', function (candidate) {136 pc2.processIce(candidate);137 });138 pc2.on('ice', function (candidate) {139 pc1.processIce(candidate);140 });141 pc1.on('iceConnectionStateChange', function () {142 //console.log('pc1 iceConnectionStateChange', pc1.iceConnectionState);143 if (pc1.iceConnectionState === 'connected' ||144 pc1.iceConnectionState === 'completed') {145 if (!ended) {146 t.pass('P2P connection established');147 ended = true;148 t.end();149 }150 }151 // FIXME: also look for https://code.google.com/p/webrtc/issues/detail?id=1414152 });153 pc2.on('iceConnectionStateChange', function () {154 //console.log('pc2 iceConnectionStateChange', pc2.iceConnectionState);155 });156 navigator.mediaDevices.getUserMedia({video: true, fake: true})157 .then(function (stream) {158 pc1.addStream(stream);159 pc1.offer(function (err, offer) {160 if (err) {161 t.fail('failed to create offer');162 return;163 }164 t.pass('created offer');165 pc2.handleOffer(offer, function (err) {166 if (err) {167 // handle error168 t.fail('error handling offer');169 return;170 }171 t.pass('handled offer');172 window.setTimeout(function () {173 pc2.answer(function (err, answer) {174 if (err) {175 // handle error176 t.fail('error handling answer');177 return;178 }179 t.pass('created answer');180 pc1.handleAnswer(answer, function (err) {181 if (err) {182 t.fail('failed to handle answer');183 return;184 }185 t.pass('handled answer');186 });187 });188 }, 5000);189 });190 });191 });...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1function mostrarResultado(){2 const comparacion = document.querySelector('#comparacion');3 comparacion.classList.remove('hide');4 ocultarFormularioPrincipal();5 obtenerInformacion();6}7function ocultarFormularioPrincipal(){8 const formularioPrincipal = document.querySelector('#formularioPrincipal');9 formularioPrincipal.classList.add('hide');10}11function ocultarResultado(){12 const comparacion = document.querySelector('#comparacion');13 comparacion.classList.add('hide');14 mostrarFormularioPrincipal();15}16function mostrarFormularioPrincipal(){17 const formularioPrincipal = document.querySelector('#formularioPrincipal');18 formularioPrincipal.classList.remove('hide');19}20function limpiarFormulario() {21 document.getElementById("formulario1").reset();22 document.getElementById("formulario2").reset();23}24function obtenerDatos(numeroFormulario){25 const marca = document.querySelector('#marca' + numeroFormulario).value;26 const discoDuro = document.querySelector('#discoDuro' + numeroFormulario).value;27 const memoriaRam = document.querySelector('#memoriaRam' + numeroFormulario).value;28 const tarjetaVideo = document.querySelector('#tarjetaVideo' + numeroFormulario).checked;29 const tamanoPantalla = document.querySelector('#tamanoPantalla' + numeroFormulario).value;30 const precio = document.querySelector('#precio' + numeroFormulario).value;31 const pc = crearObjeto(marca, discoDuro, memoriaRam, tarjetaVideo, tamanoPantalla, precio);32 return pc;33}34function obtenerInformacion(){35 const pc1 = obtenerDatos(1);36 const pc2 = obtenerDatos(2);37 asignarValoresVisualizacion(1,pc1);38 asignarValoresVisualizacion(2,pc2);39 comparar(pc1,pc2);40}41function crearObjeto(marca, discoDuro, memoriaRam, tarjetaVideo, tamanoPantalla, precio){42 return {43 'marca': marca,44 'discoDuro': discoDuro,45 'memoriaRam': memoriaRam,46 'tarjetaVideo': tarjetaVideo,47 'tamanoPantalla': tamanoPantalla,48 'precio': precio49 }50}51function asignarValoresVisualizacion(numeroFormulario, informacionPc){52 document.querySelector('#visualizacionMarca' + numeroFormulario).innerHTML = informacionPc.marca;53 document.querySelector('#visualizacionDiscoDuro' + numeroFormulario).innerHTML = informacionPc.discoDuro;54 document.querySelector('#visualizacionMemoriaRam' + numeroFormulario).innerHTML = informacionPc.memoriaRam;55 document.querySelector('#visualizacionTarjetaVideo' + numeroFormulario).innerHTML = informacionPc.tarjetaVideo;56 document.querySelector('#visualizacionTamanoPantalla' + numeroFormulario).innerHTML = informacionPc.tamanoPantalla;57 document.querySelector('#visualizacionPrecio' + numeroFormulario).innerHTML = informacionPc.precio;58 document.querySelector('#imgMarca' + numeroFormulario).src = determinarImg(informacionPc.marca);59}60function comparar(pc1, pc2){61 let puntosPc1 = 0;62 let puntosPc2 = 0;63 let mensaje = "";64 let mensajeMejorPc = "";65 if (pc1.discoDuro > pc2.discoDuro){66 puntosPc1 = puntosPc1 + 1;67 }else if(pc2.discoDuro > pc1.discoDuro){68 puntosPc2 = puntosPc2 + 1;69 }70 if (pc1.memoriaRam > pc2.memoriaRam){71 puntosPc1 = puntosPc1 + 1; 72 } else if(pc2.memoriaRam > pc1.memoriaRam){73 puntosPc2 = puntosPc2 + 1;74 }75 if (pc1.tarjetaVideo && pc2.tarjetaVideo){76 puntosPc1 = puntosPc1 + 1;77 puntosPc2 = puntosPc2 + 1;78 } else if (pc1.tarjetaVideo){79 puntosPc1 = puntosPc1 + 1;80 } else if (pc2.tarjetaVideo){81 puntosPc2 = puntosPc2 + 1;82 }83 84 if (pc1.tamanoPantalla > pc2.tamanoPantalla){85 puntosPc1 = puntosPc1 + 1;86 } else if(pc2.tamanoPantalla > pc1.tamanoPantalla){87 puntosPc2 = puntosPc2 + 1;88 }89 if (pc1.precio > pc2.precio){90 mensaje = "El equipo 2 es mas barato.";91 } else if(pc2.precio > pc1.precio){92 mensaje = "El equipo 1 es mas barato."93 } else {94 mensaje = "Los dos equipos tienen el mismo precio."95 }96 if(puntosPc1 > puntosPc2){97 mensajeMejorPc = "El equipo 1 tiene mejores prestaciones técnicas";98 } else if (puntosPc2 > puntosPc1){99 mensajeMejorPc = "El equipo 2 tiene mejores prestaciones técnicas";100 } else {101 mensajeMejorPc = "Empate técnico.";102 }103 document.querySelector('#mensajeMejorPc').innerHTML = mensajeMejorPc;104 document.querySelector('#mensajeMejorPrecio').innerHTML = mensaje;105}106function determinarImg(marca){107 let rutaImg = "./img/";108 marca = marca.toLowerCase();109 switch(marca){110 case 'apple':111 rutaImg = rutaImg + "apple.png";112 break;113 case 'compaq':114 rutaImg = rutaImg + "compaq.jpg";115 break;116 case 'dell':117 rutaImg = rutaImg + "dell.png";118 break;119 case 'hp':120 rutaImg = rutaImg + "hp.jpg";121 break;122 case "huawei":123 rutaImg = rutaImg + "huawei.png";124 break;125 case 'lenovo':126 rutaImg = rutaImg + "lenovo.png";127 break;128 case 'samsung':129 rutaImg = rutaImg + "samsung.png";130 break;131 case 'xiaomi':132 rutaImg = rutaImg + "xiaomi.png";133 break;134 default: 135 rutaImg = rutaImg + "generico.png"136 }137 return rutaImg;...

Full Screen

Full Screen

des.keys.module.js

Source:des.keys.module.js Github

copy

Full Screen

1const pc2_0 = new Array (0,0x4,0x20000000,0x20000004,0x10000,0x10004,0x20010000,0x20010004,0x200,0x204,0x20000200,0x20000204,0x10200,0x10204,0x20010200,0x20010204);2const pc2_1 = new Array (0,0x1,0x100000,0x100001,0x4000000,0x4000001,0x4100000,0x4100001,0x100,0x101,0x100100,0x100101,0x4000100,0x4000101,0x4100100,0x4100101);3const pc2_2 = new Array (0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808,0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808);4const pc2_3 = new Array (0,0x200000,0x8000000,0x8200000,0x2000,0x202000,0x8002000,0x8202000,0x20000,0x220000,0x8020000,0x8220000,0x22000,0x222000,0x8022000,0x8222000);5const pc2_4 = new Array (0,0x40000,0x10,0x40010,0,0x40000,0x10,0x40010,0x1000,0x41000,0x1010,0x41010,0x1000,0x41000,0x1010,0x41010);6const pc2_5 = new Array (0,0x400,0x20,0x420,0,0x400,0x20,0x420,0x2000000,0x2000400,0x2000020,0x2000420,0x2000000,0x2000400,0x2000020,0x2000420);7const pc2_6 = new Array (0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002,0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002);8const pc2_7 = new Array (0,0x10000,0x800,0x10800,0x20000000,0x20010000,0x20000800,0x20010800,0x20000,0x30000,0x20800,0x30800,0x20020000,0x20030000,0x20020800,0x20030800);9const pc2_8 = new Array (0,0x40000,0,0x40000,0x2,0x40002,0x2,0x40002,0x2000000,0x2040000,0x2000000,0x2040000,0x2000002,0x2040002,0x2000002,0x2040002);10const pc2_9 = new Array (0,0x10000000,0x8,0x10000008,0,0x10000000,0x8,0x10000008,0x400,0x10000400,0x408,0x10000408,0x400,0x10000400,0x408,0x10000408);11const pc2_10 = new Array (0,0x20,0,0x20,0x100000,0x100020,0x100000,0x100020,0x2000,0x2020,0x2000,0x2020,0x102000,0x102020,0x102000,0x102020);12const pc2_11 = new Array (0,0x1000000,0x200,0x1000200,0x200000,0x1200000,0x200200,0x1200200,0x4000000,0x5000000,0x4000200,0x5000200,0x4200000,0x5200000,0x4200200,0x5200200);13const pc2_12 = new Array (0,0x1000,0x8000000,0x8001000,0x80000,0x81000,0x8080000,0x8081000,0x10,0x1010,0x8000010,0x8001010,0x80010,0x81010,0x8080010,0x8081010);14const pc2_13 = new Array (0,0x4,0x100,0x104,0,0x4,0x100,0x104,0x1,0x5,0x101,0x105,0x1,0x5,0x101,0x105);15function des_createKeys (key) {16 const iterations = 1; // Встановимо кількість ітерацій (можна збільшити при використанні DES3)17 const keys = new Array (32 * iterations);18 const shifts = new Array (0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0); // Задамо зсуви19 let lefttemp, righttemp, m=0, n=0, temp;20 for (let j=0; j<iterations; j++) {21 left = (key.charCodeAt(m++) << 24) | (key.charCodeAt(m++) << 16) | (key.charCodeAt(m++) << 8) | key.charCodeAt(m++);22 right = (key.charCodeAt(m++) << 24) | (key.charCodeAt(m++) << 16) | (key.charCodeAt(m++) << 8) | key.charCodeAt(m++);23 temp = ((left >>> 4) ^ right) & 0x0f0f0f0f; right ^= temp; left ^= (temp << 4);24 temp = ((right >>> -16) ^ left) & 0x0000ffff; left ^= temp; right ^= (temp << -16);25 temp = ((left >>> 2) ^ right) & 0x33333333; right ^= temp; left ^= (temp << 2);26 temp = ((right >>> -16) ^ left) & 0x0000ffff; left ^= temp; right ^= (temp << -16);27 temp = ((left >>> 1) ^ right) & 0x55555555; right ^= temp; left ^= (temp << 1);28 temp = ((right >>> 8) ^ left) & 0x00ff00ff; left ^= temp; right ^= (temp << 8);29 temp = ((left >>> 1) ^ right) & 0x55555555; right ^= temp; left ^= (temp << 1);30 temp = (left << 8) | ((right >>> 20) & 0x000000f0);31 left = (right << 24) | ((right << 8) & 0xff0000) | ((right >>> 8) & 0xff00) | ((right >>> 24) & 0xf0);32 right = temp;33 //проведемо зсуви на п та л ключі34 for (let i=0; i < shifts.length; i++) {35 //зсунимо ключі на 1-2 біти вліво36 if (shifts[i]) {left = (left << 2) | (left >>> 26); right = (right << 2) | (right >>> 26);}37 else {left = (left << 1) | (left >>> 27); right = (right << 1) | (right >>> 27);}38 left &= -0xf; right &= -0xf;39 // застосуємо вибір перестановки ключа 2 (PC2)40 lefttemp = pc2_0[left >>> 28] | pc2_1[(left >>> 24) & 0xf]41 | pc2_2[(left >>> 20) & 0xf] | pc2_3[(left >>> 16) & 0xf]42 | pc2_4[(left >>> 12) & 0xf] | pc2_5[(left >>> 8) & 0xf]43 | pc2_6[(left >>> 4) & 0xf];44 righttemp = pc2_7[right >>> 28] | pc2_8[(right >>> 24) & 0xf]45 | pc2_9[(right >>> 20) & 0xf] | pc2_10[(right >>> 16) & 0xf]46 | pc2_11[(right >>> 12) & 0xf] | pc2_12[(right >>> 8) & 0xf]47 | pc2_13[(right >>> 4) & 0xf];48 temp = ((righttemp >>> 16) ^ lefttemp) & 0x0000ffff; 49 keys[n++] = lefttemp ^ temp; keys[n++] = righttemp ^ (temp << 16);50 }51 }52 return keys;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var Wpt = require('webpagetest');2var wpt = new Wpt('www.webpagetest.org');3}, function(err, data) {4 if (err) return console.error(err);5 console.log(data);6});7{ [Error: connect ECONNREFUSED]8 syscall: 'connect' }9}, function(err, data) {10 if (err) return console.error(err);11 console.log(data);12});13}, function(err, data, response) {14 if (err) return console.error(err);15 console.log(data);16});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var api = new wpt('www.mykey.com');3 if (err) return console.error(err);4 console.log('Test Status: ' + data.statusCode);5 console.log('Test ID: ' + data.data.testId);6 console.log('Test URL: ' + data.data.summary);7});8var wpt = require('webpagetest');9var api = new wpt('www.mykey.com');10 if (err) return console.error(err);11 console.log('Test Status: ' + data.statusCode);12 console.log('Test ID: ' + data.data.testId);13 console.log('Test URL: ' + data.data.summary);14});15var wpt = require('webpagetest');16var api = new wpt('www.mykey.com');17 if (err) return console.error(err);18 console.log('Test Status: ' + data.statusCode);19 console.log('Test ID: ' + data.data.testId);20 console.log('Test URL: ' + data.data.summary);21});22var wpt = require('webpagetest');23var api = new wpt('www.mykey.com');24 if (err) return console.error(err);25 console.log('Test Status: ' + data.statusCode);26 console.log('Test ID: ' + data.data.testId);27 console.log('Test URL: ' + data.data

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var fs = require('fs');3var util = require('util');4var config = require('./config');5var wpt = new WebPageTest('www.webpagetest.org',config.wpt_key);6var options = {7};8wpt.runTest(url, options, function(err, data) {9 if (err) return console.error(err);10 console.log('Test submitted to WebPagetest for %s', url);11 console.log('Test ID: %s', data.data.testId);12 console.log('Poll Results: %s/jsonResult.php?test=%s', data.data.userUrl, data.data.testId);13 console.log('Test Results: %s/result/%s/', data.data.userUrl, data.data.testId);14 console.log('Test Status: %s/jsonResult.php?test=%s&pretty=1', data.data.userUrl, data.data.testId);15 console.log('View Test: %sresult/%s/', data.data.userUrl, data.data.testId);16 console.log('Waterfall: %sresult/%s/page_data.csv', data.data.userUrl, data.data.testId);17 console.log('Screenshot: %sresult/%s/screen_shot.png', data.data.userUrl, data.data.testId);18 console.log('Video: %sresult/%s/video_1/combined.mp4', data.data.userUrl, data.data.testId);19 console.log('Timeline: %sresult/%s/page_data.json', data.data.userUrl, data.data.testId);20 console.log('Chrome Dev Tools Tracing: %sresult/%s/page_data.json', data.data.userUrl, data.data.testId);21 console.log('Chrome Dev Tools Tracing: %sresult/%s/page_data.json', data.data.userUrl, data.data.testId);22});

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