How to use TestStates method in wpt

Best JavaScript code snippet using wpt

background_tokenizer_test.js

Source:background_tokenizer_test.js Github

copy

Full Screen

1/* ***** BEGIN LICENSE BLOCK *****2 * Distributed under the BSD license:3 *4 * Copyright (c) 2010, Ajax.org B.V.5 * All rights reserved.6 * 7 * Redistribution and use in source and binary forms, with or without8 * modification, are permitted provided that the following conditions are met:9 * * Redistributions of source code must retain the above copyright10 * notice, this list of conditions and the following disclaimer.11 * * Redistributions in binary form must reproduce the above copyright12 * notice, this list of conditions and the following disclaimer in the13 * documentation and/or other materials provided with the distribution.14 * * Neither the name of Ajax.org B.V. nor the15 * names of its contributors may be used to endorse or promote products16 * derived from this software without specific prior written permission.17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE21 * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.28 *29 * ***** END LICENSE BLOCK ***** */30if (typeof process !== "undefined") {31 require("amd-loader");32}33define(function(require, exports, module) {34"use strict";35var EditSession = require("./edit_session").EditSession;36var JavaScriptMode = require("./mode/javascript").Mode;37var LuaMode = require("./mode/lua").Mode;38var Range = require("./range").Range;39var assert = require("./test/assertions");40function forceTokenize(session, startLine) {41 for (var i = startLine || 0, l = session.getLength(); i < l; i++)42 session.getTokens(i);43}44function testStates(session, states) {45 for (var i = 0, l = session.getLength(); i < l; i++)46 assert.equal(session.bgTokenizer.states[i], states[i]);47 assert.ok(l == states.length);48}49module.exports = {50 "test background tokenizer update on session change" : function() {51 var doc = new EditSession([52 "/*",53 "*/",54 "var juhu"55 ]);56 doc.setMode("./mode/javascript"); 57 58 forceTokenize(doc);59 testStates(doc, ["comment1", "start", "no_regex"]);60 61 doc.remove(new Range(0,2,1,2));62 testStates(doc, [null, "no_regex"]);63 64 forceTokenize(doc);65 testStates(doc, ["comment1", "comment1"]);66 67 doc.insert({row:0, column:2}, "\n*/");68 testStates(doc, [undefined, undefined, "comment1"]);69 70 forceTokenize(doc);71 testStates(doc, ["comment1", "start", "no_regex"]);72 },73 "test background tokenizer sends update event" : function() {74 var doc = new EditSession([75 "/*",76 "var",77 "juhu",78 "*/"79 ]);80 doc.setMode("./mode/javascript");81 82 var updateEvent = null;83 doc.bgTokenizer.on("update", function(e) {84 updateEvent = e.data;85 });86 function checkEvent(first, last) {87 assert.ok(!updateEvent, "unneccessary update event");88 doc.bgTokenizer.running = 1;89 doc.bgTokenizer.$worker();90 assert.ok(updateEvent);91 assert.equal([first, last] + "", 92 [updateEvent.first, updateEvent.last] + "");93 updateEvent = null;94 }95 96 forceTokenize(doc);97 var comment = "comment1";98 testStates(doc, [comment, comment, comment, "start"]);99 100 doc.remove(new Range(0,0,0,2));101 testStates(doc, [comment, comment, comment, "start"]);102 103 checkEvent(0, 3);104 testStates(doc, ["start", "no_regex", "no_regex", "regex"]);105 106 // insert /* and and press down several times quickly107 doc.insert({row:0, column:0}, "/*");108 doc.getTokens(0);109 doc.getTokens(1);110 doc.getTokens(2);111 checkEvent(0, 3);112 113 forceTokenize(doc);114 testStates(doc, [comment, comment, comment, "start"]);115 },116 "test background tokenizer sends update event 2" : function(next) {117 var doc = new EditSession([118 "-[[",119 "juhu",120 "kinners]]--",121 ""122 ]);123 doc.setMode("./mode/lua");124 forceTokenize(doc);125 var string = "bracketedString,2,start";126 var comment = "bracketedComment,2,start";127 testStates(doc, [string, string, "start", "start"]);128 129 doc.insert({row:0, column:0}, "-");130 forceTokenize(doc);131 doc.bgTokenizer.once("update", function(e) {132 assert.equal([0, 4] + "", [e.data.first, e.data.last] + "");133 testStates(doc, [comment, comment, "start", "start"]);134 next();135 });136 doc.bgTokenizer.running = 1;137 doc.bgTokenizer.$worker();138 }139};140});141if (typeof module !== "undefined" && module === require.main) {142 require("asyncjs").test.testcase(module.exports).exec();...

Full Screen

Full Screen

dataUnavailableTests.js

Source:dataUnavailableTests.js Github

copy

Full Screen

1'use strict';2const TestStates = Object.freeze({3 "ShouldSucceedScheduleRAF": 1,4 "ShouldFailScheduleRAF": 2,5 "ShouldSucceedTestDone": 3,6});7const dataUnavailableTestFunctionGenerator = function(isCpuOptimized) {8 return (session, controller, t, sessionObjects) => {9 let state = TestStates.ShouldSucceedScheduleRAF;10 return session.requestReferenceSpace('viewer').then((viewerSpace) => {11 let done = false;12 const glBinding = new XRWebGLBinding(session, sessionObjects.gl);13 const rafCb = function(time, frame) {14 const pose = frame.getViewerPose(viewerSpace);15 for(const view of pose.views) {16 const depthInformation = isCpuOptimized ? frame.getDepthInformation(view)17 : glBinding.getDepthInformation(view);18 if (state == TestStates.ShouldSucceedScheduleRAF19 || state == TestStates.ShouldSucceedTestDone) {20 t.step(() => {21 assert_not_equals(depthInformation, null);22 });23 } else {24 t.step(() => {25 assert_equals(depthInformation, null);26 });27 }28 }29 switch(state) {30 case TestStates.ShouldSucceedScheduleRAF:31 controller.clearDepthSensingData();32 state = TestStates.ShouldFailScheduleRAF;33 session.requestAnimationFrame(rafCb);34 break;35 case TestStates.ShouldFailScheduleRAF:36 controller.setDepthSensingData(DEPTH_SENSING_DATA);37 state = TestStates.ShouldSucceedTestDone;38 session.requestAnimationFrame(rafCb);39 break;40 case TestStates.ShouldSucceedTestDone:41 done = true;42 break;43 }44 };45 session.requestAnimationFrame(rafCb);46 return t.step_wait(() => done);47 });48 };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wptClient = wpt('www.webpagetest.org');3 console.log(data);4});5### WPTClient(options)6### WPTClient.testState(testId, callback)7### WPTClient.testResults(testId, callback)8### WPTClient.runTest(url, options, callback)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var config = require('./config.js');3var wpt = new wpt(config);4wpt.TestStates({testId: 170509_9X_4d4}, function(err, data) {5 if (err) {6 console.log(err);7 }8 else {9 console.log(data);10 }11});

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