How to use integrity method in wpt

Best JavaScript code snippet using wpt

test-policy-scopes-integrity.js

Source:test-policy-scopes-integrity.js Github

copy

Full Screen

1'use strict';2// Flags: --expose-internals3const common = require('../common');4if (!common.hasCrypto) common.skip('missing crypto');5common.requireNoPackageJSONAbove();6const Manifest = require('internal/policy/manifest').Manifest;7const assert = require('assert');8// #region files9{10 const baseURLs = [11 // Localhost is special cased in spec12 'file://localhost/root',13 'file:///root',14 'file:///',15 'file:///root/dir1',16 'file:///root/dir1/',17 'file:///root/dir1/dir2',18 'file:///root/dir1/dir2/',19 ];20 {21 const manifest = new Manifest({22 scopes: {23 'file:///': {24 integrity: true25 }26 }27 });28 for (const href of baseURLs) {29 assert.strictEqual(30 manifest.assertIntegrity(href),31 true32 );33 assert.strictEqual(34 manifest.assertIntegrity(href, null),35 true36 );37 assert.strictEqual(38 manifest.assertIntegrity(href, ''),39 true40 );41 }42 }43 {44 const manifest = new Manifest({45 scopes: {46 'file:': {47 integrity: true48 }49 }50 });51 for (const href of baseURLs) {52 assert.strictEqual(53 manifest.assertIntegrity(href),54 true55 );56 assert.strictEqual(57 manifest.assertIntegrity(href, null),58 true59 );60 assert.strictEqual(61 manifest.assertIntegrity(href, ''),62 true63 );64 }65 }66 {67 const manifest = new Manifest({68 resources: {69 'file:///root/dir1/isolated': {},70 'file:///root/dir1/cascade': {71 cascade: true72 }73 },74 scopes: {75 'file:///root/dir1/': {76 integrity: true,77 },78 'file:///root/dir1/dir2/': {79 cascade: true,80 },81 'file:///root/dir1/censor/': {82 },83 }84 });85 assert.throws(86 () => {87 manifest.assertIntegrity('file:///root/dir1/isolated');88 },89 /ERR_MANIFEST_ASSERT_INTEGRITY/90 );91 assert.strictEqual(92 manifest.assertIntegrity('file:///root/dir1/cascade'),93 true94 );95 assert.strictEqual(96 manifest.assertIntegrity('file:///root/dir1/enoent'),97 true98 );99 assert.strictEqual(100 manifest.assertIntegrity('file:///root/dir1/dir2/enoent'),101 true102 );103 assert.throws(104 () => {105 manifest.assertIntegrity('file:///root/dir1/censor/enoent');106 },107 /ERR_MANIFEST_ASSERT_INTEGRITY/108 );109 }110}111// #endregion112// #region data113{114 const baseURLs = [115 'data:text/javascript,0',116 'data:text/javascript,0/1',117 ];118 {119 const manifest = new Manifest({120 scopes: {121 'data:text/': {122 integrity: true123 }124 }125 });126 for (const href of baseURLs) {127 assert.throws(128 () => {129 manifest.assertIntegrity(href);130 },131 /ERR_MANIFEST_ASSERT_INTEGRITY/132 );133 }134 }135 {136 const manifest = new Manifest({137 scopes: {138 'data:/': {139 integrity: true140 }141 }142 });143 for (const href of baseURLs) {144 assert.throws(145 () => {146 manifest.assertIntegrity(href);147 },148 /ERR_MANIFEST_ASSERT_INTEGRITY/149 );150 }151 }152 {153 const manifest = new Manifest({154 scopes: {155 'data:': {156 integrity: true157 }158 }159 });160 for (const href of baseURLs) {161 assert.strictEqual(manifest.assertIntegrity(href), true);162 }163 }164 {165 const manifest = new Manifest({166 scopes: {167 'data:text/javascript,0/': {168 integrity: true169 },170 }171 });172 for (const href of baseURLs) {173 assert.throws(174 () => {175 manifest.assertIntegrity(href);176 },177 /ERR_MANIFEST_ASSERT_INTEGRITY/178 );179 }180 }181}182// #endregion183// #region blob184{185 {186 const manifest = new Manifest({187 scopes: {188 'https://example.com/': {189 integrity: true190 }191 }192 });193 assert.strictEqual(194 manifest.assertIntegrity('blob:https://example.com/has-origin'),195 true196 );197 }198 {199 const manifest = new Manifest({200 scopes: {201 }202 });203 assert.throws(204 () => {205 manifest.assertIntegrity('blob:https://example.com/has-origin');206 },207 /ERR_MANIFEST_ASSERT_INTEGRITY/208 );209 }210 {211 const manifest = new Manifest({212 scopes: {213 'blob:https://example.com/has-origin': {214 cascade: true215 }216 }217 });218 assert.throws(219 () => {220 manifest.assertIntegrity('blob:https://example.com/has-origin');221 },222 /ERR_MANIFEST_ASSERT_INTEGRITY/223 );224 }225 {226 const manifest = new Manifest({227 resources: {228 'blob:https://example.com/has-origin': {229 cascade: true230 }231 },232 scopes: {233 'https://example.com': {234 integrity: true235 }236 }237 });238 assert.strictEqual(239 manifest.assertIntegrity('blob:https://example.com/has-origin'),240 true241 );242 }243 {244 const manifest = new Manifest({245 scopes: {246 'blob:': {247 integrity: true248 },249 'https://example.com': {250 cascade: true251 }252 }253 });254 assert.throws(255 () => {256 manifest.assertIntegrity('blob:https://example.com/has-origin');257 },258 /ERR_MANIFEST_ASSERT_INTEGRITY/259 );260 assert.strictEqual(261 manifest.assertIntegrity('blob:foo'),262 true263 );264 }265}266// #endregion267// #startonerror268{269 const manifest = new Manifest({270 scopes: {271 'file:///': {272 integrity: true273 }274 },275 onerror: 'throw'276 });277 assert.throws(278 () => {279 manifest.assertIntegrity('http://example.com');280 },281 /ERR_MANIFEST_ASSERT_INTEGRITY/282 );283}284{285 assert.throws(286 () => {287 new Manifest({288 scopes: {289 'file:///': {290 integrity: true291 }292 },293 onerror: 'unknown'294 });295 },296 /ERR_MANIFEST_UNKNOWN_ONERROR/297 );298}...

Full Screen

Full Screen

Detail.js

Source:Detail.js Github

copy

Full Screen

1/*+***********************************************************************************2 * The contents of this file are subject to the vtiger CRM Public License Version 1.03 * ("License"); You may not use this file except in compliance with the License4 * The Original Code is: vtiger CRM Open Source5 * The Initial Developer of the Original Code is vtiger.6 * Portions created by vtiger are Copyright (C) vtiger.7 * All Rights Reserved.8 *************************************************************************************/9Vtiger_Detail_Js("Documents_Detail_Js", {10 11 //It stores the CheckFileIntegrity response data12 checkFileIntegrityResponseCache : {},13 14 /*15 * function to trigger CheckFileIntegrity action16 * @param: CheckFileIntegrity url.17 */18 checkFileIntegrity : function(checkFileIntegrityUrl) {19 Documents_Detail_Js.getFileIntegrityResponse(checkFileIntegrityUrl).then(20 function(data){21 Documents_Detail_Js.displayCheckFileIntegrityResponse(data);22 }23 );24 },25 26 /*27 * function to get the CheckFileIntegrity response data28 */29 getFileIntegrityResponse : function(params){30 var aDeferred = jQuery.Deferred();31 32 //Check in the cache 33 if(!(jQuery.isEmptyObject(Documents_Detail_Js.checkFileIntegrityResponseCache))) {34 aDeferred.resolve(Documents_Detail_Js.checkFileIntegrityResponseCache);35 }36 else{37 AppConnector.request(params).then(38 function(data) {39 //store it in the cache, so that we dont do multiple request40 Documents_Detail_Js.checkFileIntegrityResponseCache = data;41 aDeferred.resolve(Documents_Detail_Js.checkFileIntegrityResponseCache);42 }43 );44 }45 return aDeferred.promise();46 },47 48 /*49 * function to display the CheckFileIntegrity message50 */51 displayCheckFileIntegrityResponse : function(data) {52 var result = data['result'];53 var success = result['success'];54 var message = result['message'];55 var params = {};56 if(success) {57 params = {58 text: message,59 type: 'success'60 }61 } else {62 params = {63 text: message,64 type: 'error'65 }66 }67 Documents_Detail_Js.showNotify(params);68 },69 70 //This will show the messages of CheckFileIntegrity using pnotify71 showNotify : function(customParams) {72 var params = {73 title: app.vtranslate('JS_CHECK_FILE_INTEGRITY'),74 text: customParams.text,75 type: customParams.type,76 width: '30%',77 delay: '2000'78 };79 Vtiger_Helper_Js.showPnotify(params);80 },81 triggerSendEmail : function(recordIds) {82 var params = {83 "module" : "Documents",84 "view" : "ComposeEmail",85 "documentIds" : recordIds86 };87 var emailEditInstance = new Emails_MassEdit_Js();88 emailEditInstance.showComposeEmailForm(params);89 }90 ...

Full Screen

Full Screen

integrity.js

Source:integrity.js Github

copy

Full Screen

1if (this.document === undefined) {2 importScripts("/resources/testharness.js");3 importScripts("../resources/utils.js");4}5function integrity(desc, url, integrity, shouldPass) {6 if (shouldPass) {7 promise_test(function(test) {8 return fetch(url, {'integrity': integrity}).then(function(resp) {9 assert_equals(resp.status, 200, "Response's status is 200");10 });11 }, desc);12 } else {13 promise_test(function(test) {14 return promise_rejects(test, new TypeError(), fetch(url, {'integrity': integrity}));15 }, desc);16 }17}18var topSha256 = "sha256-KHIDZcXnR2oBHk9DrAA+5fFiR6JjudYjqoXtMR1zvzk=";19var topSha384 = "sha384-MgZYnnAzPM/MjhqfOIMfQK5qcFvGZsGLzx4Phd7/A8fHTqqLqXqKo8cNzY3xEPTL";20var topSha512 = "sha512-D6yns0qxG0E7+TwkevZ4Jt5t7Iy3ugmAajG/dlf6Pado1JqTyneKXICDiqFIkLMRExgtvg8PlxbKTkYfRejSOg==";21var invalidSha256 = "sha256-dKUcPOn/AlUjWIwcHeHNqYXPlvyGiq+2dWOdFcE+24I=";22var invalidSha512 = "sha512-oUceBRNxPxnY60g/VtPCj2syT4wo4EZh2CgYdWy9veW8+OsReTXoh7dizMGZafvx9+QhMS39L/gIkxnPIn41Zg==";23var url = "../resources/top.txt";24var corsUrl = "http://{{host}}:{{ports[http][1]}}" + dirname(location.pathname) + RESOURCES_DIR + "top.txt";25/* Enable CORS*/26corsUrl += "?pipe=header(Access-Control-Allow-Origin,*)";27integrity("Empty string integrity", url, "", true);28integrity("SHA-256 integrity", url, topSha256, true);29integrity("SHA-384 integrity", url, topSha384, true);30integrity("SHA-512 integrity", url, topSha512, true);31integrity("Invalid integrity", url, invalidSha256, false);32integrity("Multiple integrities: valid stronger than invalid", url, invalidSha256 + " " + topSha384, true);33integrity("Multiple integrities: invalid stronger than valid", url, invalidSha512 + " " + topSha384, false);34integrity("Multiple integrities: invalid as strong as valid", url, invalidSha512 + " " + topSha512, true);35integrity("Multiple integrities: both are valid", url, topSha384 + " " + topSha512, true);36integrity("Multiple integrities: both are invalid", url, invalidSha256 + " " + invalidSha512, false);37integrity("CORS empty integrity", corsUrl, "", true);38integrity("CORS SHA-512 integrity", corsUrl, topSha512, true);39integrity("CORS invalid integrity", corsUrl, invalidSha512, false);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var WebPageTest = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var fs = require('fs');4var location = "Dulles:Chrome";5var options = {6};7var testId = "";8var testResults = "";9var testResultsJSON = "";10var testResultsJSON2 = "";11var testResultsJSON3 = "";12var testResultsJSON4 = "";13var testResultsJSON5 = "";14var testResultsJSON6 = "";15var testResultsJSON7 = "";16var testResultsJSON8 = "";17var testResultsJSON9 = "";18var testResultsJSON10 = "";19var testResultsJSON11 = "";20var testResultsJSON12 = "";21var testResultsJSON13 = "";22var testResultsJSON14 = "";23var testResultsJSON15 = "";24var testResultsJSON16 = "";25var testResultsJSON17 = "";26var testResultsJSON18 = "";27var testResultsJSON19 = "";28var testResultsJSON20 = "";29var testResultsJSON21 = "";30var testResultsJSON22 = "";31var testResultsJSON23 = "";32var testResultsJSON24 = "";33var testResultsJSON25 = "";34var testResultsJSON26 = "";35var testResultsJSON27 = "";36var testResultsJSON28 = "";37var testResultsJSON29 = "";38var testResultsJSON30 = "";39var testResultsJSON31 = "";40var testResultsJSON32 = "";41var testResultsJSON33 = "";42var testResultsJSON34 = "";43var testResultsJSON35 = "";44var testResultsJSON36 = "";45var testResultsJSON37 = "";46var testResultsJSON38 = "";47var testResultsJSON39 = "";48var testResultsJSON40 = "";49var testResultsJSON41 = "";50var testResultsJSON42 = "";51var testResultsJSON43 = "";52var testResultsJSON44 = "";53var testResultsJSON45 = "";54var testResultsJSON46 = "";55var testResultsJSON47 = "";56var testResultsJSON48 = "";57var testResultsJSON49 = "";58var testResultsJSON50 = "";59var testResultsJSON51 = "";

Full Screen

Using AI Code Generation

copy

Full Screen

1var WebPageTest = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.4b7c1b1b1b1b1b1b1b1b1b1b1b1b1b1b');3wpt.runTest(url, {4}, function(err, data) {5 if (err) return console.error(err);6 console.log('Test status:', data.statusText);7 console.log('Test ID:', data.data.testId);8 console.log('Test URL:', data.data.summary);9 console.log('Test results:', data.data.runs[1].firstView);10 console.log('Test results:', data.data.runs[1].firstView.integrity);11 console.log('Test results:', data.data.runs[1].firstView.integrity.score);12 console.log('Test results:', data.data.runs[1].firstView.integrity.score.performance);13 console.log('Test results:', data.data.runs[1].firstView.integrity.score.privacy);14 console.log('Test results:', data.data.runs[1].firstView.integrity.score.security);15 console.log('Test results:', data.data.runs[1].firstView.integrity.score.usability);16 console.log('Test results:', data.data.runs[1].firstView.integrity.score.accessibility);17 console.log('Test results:', data.data.runs[1].firstView.integrity.score.maintenance);18 console.log('Test results:', data.data.runs[1].firstView.integrity.score.quality);19 console.log('Test results:', data.data.runs[1].firstView.integrity.score.resilience);20 console.log('Test results:', data.data.runs[1].firstView.integrity.score.performance.score);21 console.log('Test results:', data.data.runs[1].firstView.integrity.score.performance.score.performance);22 console.log('Test results:', data.data.runs[1].firstView.integrity.score.performance.score.privacy);23 console.log('Test results:', data.data.runs[1].firstView.integrity.score.performance.score.security);24 console.log('Test results:', data.data.run

Full Screen

Using AI Code Generation

copy

Full Screen

1var WPT = require('wpt-api');2var wpt = new WPT('A.2c2f0e2a2c2f0e2a2c2f0e2a2c2f0e2a');3var options = {4 videoParams: {5 },6};7wpt.runTest(options, function(err, data) {8 if (err) {9 return console.error(err);10 }11 console.log(data);12 var testId = data.data.testId;13 wpt.getTestStatus(testId, function(err, data) {14 if (err) {15 return console.error(err);16 }17 console.log(data);18 wpt.getTestResults(testId, function(err, data) {19 if (err) {20 return console.error(err);21 }22 console.log(data.data);23 wpt.getTestVideo(testId, function(err, data) {24 if (err) {25 return console.error(err);26 }27 console.log(data);28 });29 });30 });31});

Full Screen

Using AI Code Generation

copy

Full Screen

1function wptTest(url, key) {2 var wpt = require('webpagetest');3 var wpt = new WebPageTest('www.webpagetest.org', key);4 var testId;5 var results;6 wpt.runTest(url, {7 }, function (err, data) {8 if (err) throw err;9 testId = data.data.testId;10 wpt.getTestResults(testId, function (err, data) {11 if (err) throw err;12 results = data.data;13 console.log(results);14 });15 });16}17function wptTest(url, key) {18 var wpt = require('webpagetest');19 var wpt = new WebPageTest('www.webpagetest.org', key);20 var testId;21 var results;22 wpt.runTest(url, {23 }, function (err, data) {24 if (err) throw err;25 testId = data.data.testId;26 wpt.getTestResults(testId, function (err, data) {27 if (err) throw err;28 results = data.data;29 console.log(results);30 });31 });32}33function wptTest(url, key) {34 var wpt = require('webpagetest');35 var wpt = new WebPageTest('www.webpagetest.org', key);36 var testId;37 var results;38 wpt.runTest(url, {39 }, function (err, data) {

Full Screen

Using AI Code Generation

copy

Full Screen

1function wptIntegrity(url, key, callback) {2 var data = {3 };4 var options = {5 path: '/runtest.php?' + querystring.stringify(data)6 };7 var req = https.get(options, function(res) {8 var output = '';9 res.setEncoding('utf8');10 res.on('data', function (chunk) {11 output += chunk;12 });13 res.on('end', function() {14 var obj = JSON.parse(output);15 callback(obj.data.testId);16 });17 });18}19function wptResults(testId, key, callback) {20 var data = {21 };22 var options = {23 path: '/jsonResult.php?' + querystring.stringify(data)24 };25 var req = https.get(options, function(res) {26 var output = '';27 res.setEncoding('utf8');28 res.on('data', function (chunk) {29 output += chunk;30 });31 res.on('end', function() {32 var obj = JSON.parse(output);33 callback(obj);34 });35 });36}37function wptResults2(testId, key, callback) {38 var data = {39 };40 var options = {41 path: '/jsonResult.php?' + querystring.stringify(data)

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