How to use realm method in wpt

Best JavaScript code snippet using wpt

realms.window.js

Source:realms.window.js Github

copy

Full Screen

1'use strict';2// Test that objects created by the TextEncoderStream and TextDecoderStream APIs3// are created in the correct realm. The tests work by creating an iframe for4// each realm and then posting Javascript to them to be evaluated. Inputs and5// outputs are passed around via global variables in each realm's scope.6// Async setup is required before creating any tests, so require done() to be7// called.8setup({explicit_done: true});9function createRealm() {10 let iframe = document.createElement('iframe');11 const scriptEndTag = '<' + '/script>';12 iframe.srcdoc = `<!doctype html>13<script>14onmessage = event => {15 if (event.source !== window.parent) {16 throw new Error('unexpected message with source ' + event.source);17 }18 eval(event.data);19};20${scriptEndTag}`;21 iframe.style.display = 'none';22 document.body.appendChild(iframe);23 let realmPromiseResolve;24 const realmPromise = new Promise(resolve => {25 realmPromiseResolve = resolve;26 });27 iframe.onload = () => {28 realmPromiseResolve(iframe.contentWindow);29 };30 return realmPromise;31}32async function createRealms() {33 // All realms are visible on the global object so they can access each other.34 // The realm that the constructor function comes from.35 window.constructorRealm = await createRealm();36 // The realm in which the constructor object is called.37 window.constructedRealm = await createRealm();38 // The realm in which reading happens.39 window.readRealm = await createRealm();40 // The realm in which writing happens.41 window.writeRealm = await createRealm();42 // The realm that provides the definitions of Readable and Writable methods.43 window.methodRealm = await createRealm();44 await evalInRealmAndWait(methodRealm, `45 window.ReadableStreamDefaultReader =46 new ReadableStream().getReader().constructor;47 window.WritableStreamDefaultWriter =48 new WritableStream().getWriter().constructor;49`);50 window.readMethod = methodRealm.ReadableStreamDefaultReader.prototype.read;51 window.writeMethod = methodRealm.WritableStreamDefaultWriter.prototype.write;52}53// In order for values to be visible between realms, they need to be54// global. To prevent interference between tests, variable names are generated55// automatically.56const id = (() => {57 let nextId = 0;58 return () => {59 return `realmsId${nextId++}`;60 };61})();62// Eval string "code" in the content of realm "realm". Evaluation happens63// asynchronously, meaning it hasn't happened when the function returns.64function evalInRealm(realm, code) {65 realm.postMessage(code, window.origin);66}67// Same as evalInRealm() but returns a Promise which will resolve when the68// function has actually.69async function evalInRealmAndWait(realm, code) {70 const resolve = id();71 const waitOn = new Promise(r => {72 realm[resolve] = r;73 });74 evalInRealm(realm, code);75 evalInRealm(realm, `${resolve}();`);76 await waitOn;77}78// The same as evalInRealmAndWait but returns the result of evaluating "code" as79// an expression.80async function evalInRealmAndReturn(realm, code) {81 const myId = id();82 await evalInRealmAndWait(realm, `window.${myId} = ${code};`);83 return realm[myId];84}85// Constructs an object in constructedRealm and copies it into readRealm and86// writeRealm. Returns the id that can be used to access the object in those87// realms. |what| can contain constructor arguments.88async function constructAndStore(what) {89 const objId = id();90 // Call |constructorRealm|'s constructor from inside |constructedRealm|.91 writeRealm[objId] = await evalInRealmAndReturn(92 constructedRealm, `new parent.constructorRealm.${what}`);93 readRealm[objId] = writeRealm[objId];94 return objId;95}96// Calls read() on the readable side of the TransformStream stored in97// readRealm[objId]. Locks the readable side as a side-effect.98function readInReadRealm(objId) {99 return evalInRealmAndReturn(readRealm, `100parent.readMethod.call(window.${objId}.readable.getReader())`);101}102// Calls write() on the writable side of the TransformStream stored in103// writeRealm[objId], passing |value|. Locks the writable side as a104// side-effect.105function writeInWriteRealm(objId, value) {106 const valueId = id();107 writeRealm[valueId] = value;108 return evalInRealmAndReturn(writeRealm, `109parent.writeMethod.call(window.${objId}.writable.getWriter(),110 window.${valueId})`);111}112window.onload = () => {113 createRealms().then(() => {114 runGenericTests('TextEncoderStream');115 runTextEncoderStreamTests();116 runGenericTests('TextDecoderStream');117 runTextDecoderStreamTests();118 done();119 });120};121function runGenericTests(classname) {122 promise_test(async () => {123 const obj = await evalInRealmAndReturn(124 constructedRealm, `new parent.constructorRealm.${classname}()`);125 assert_equals(obj.constructor, constructorRealm[classname],126 'obj should be in constructor realm');127 }, `a ${classname} object should be associated with the realm the ` +128 'constructor came from');129 promise_test(async () => {130 const objId = await constructAndStore(classname);131 const readableGetterId = id();132 readRealm[readableGetterId] = Object.getOwnPropertyDescriptor(133 methodRealm[classname].prototype, 'readable').get;134 const writableGetterId = id();135 writeRealm[writableGetterId] = Object.getOwnPropertyDescriptor(136 methodRealm[classname].prototype, 'writable').get;137 const readable = await evalInRealmAndReturn(138 readRealm, `${readableGetterId}.call(${objId})`);139 const writable = await evalInRealmAndReturn(140 writeRealm, `${writableGetterId}.call(${objId})`);141 assert_equals(readable.constructor, constructorRealm.ReadableStream,142 'readable should be in constructor realm');143 assert_equals(writable.constructor, constructorRealm.WritableStream,144 'writable should be in constructor realm');145 }, `${classname}'s readable and writable attributes should come from the ` +146 'same realm as the constructor definition');147}148function runTextEncoderStreamTests() {149 promise_test(async () => {150 const objId = await constructAndStore('TextEncoderStream');151 const writePromise = writeInWriteRealm(objId, 'A');152 const result = await readInReadRealm(objId);153 await writePromise;154 assert_equals(result.constructor, constructorRealm.Object,155 'result should be in constructor realm');156 assert_equals(result.value.constructor, constructorRealm.Uint8Array,157 'chunk should be in constructor realm');158 }, 'the output chunks when read is called after write should come from the ' +159 'same realm as the constructor of TextEncoderStream');160 promise_test(async () => {161 const objId = await constructAndStore('TextEncoderStream');162 const chunkPromise = readInReadRealm(objId);163 writeInWriteRealm(objId, 'A');164 // Now the read() should resolve.165 const result = await chunkPromise;166 assert_equals(result.constructor, constructorRealm.Object,167 'result should be in constructor realm');168 assert_equals(result.value.constructor, constructorRealm.Uint8Array,169 'chunk should be in constructor realm');170 }, 'the output chunks when write is called with a pending read should come ' +171 'from the same realm as the constructor of TextEncoderStream');172 // There is not absolute consensus regarding what realm exceptions should be173 // created in. Implementations may vary. The expectations in exception-related174 // tests may change in future once consensus is reached.175 promise_test(async t => {176 const objId = await constructAndStore('TextEncoderStream');177 // Read first to relieve backpressure.178 const readPromise = readInReadRealm(objId);179 // promise_rejects() does not permit directly inspecting the rejection, so180 // it's necessary to write it out long-hand.181 let writeSucceeded = false;182 try {183 // Write an invalid chunk.184 await writeInWriteRealm(objId, {185 toString() { return {}; }186 });187 writeSucceeded = true;188 } catch (err) {189 assert_equals(err.constructor, constructorRealm.TypeError,190 'write TypeError should come from constructor realm');191 }192 assert_false(writeSucceeded, 'write should fail');193 let readSucceeded = false;194 try {195 await readPromise;196 readSucceeded = true;197 } catch (err) {198 assert_equals(err.constructor, constructorRealm.TypeError,199 'read TypeError should come from constructor realm');200 }201 assert_false(readSucceeded, 'read should fail');202 }, 'TypeError for unconvertable chunk should come from constructor realm ' +203 'of TextEncoderStream');204}205function runTextDecoderStreamTests() {206 promise_test(async () => {207 const objId = await constructAndStore('TextDecoderStream');208 const writePromise = writeInWriteRealm(objId, new Uint8Array([65]));209 const result = await readInReadRealm(objId);210 await writePromise;211 assert_equals(result.constructor, constructorRealm.Object,212 'result should be in constructor realm');213 // A string is not an object, so doesn't have an associated realm. Accessing214 // string properties will create a transient object wrapper belonging to the215 // current realm. So checking the realm of result.value is not useful.216 }, 'the result object when read is called after write should come from the ' +217 'same realm as the constructor of TextDecoderStream');218 promise_test(async () => {219 const objId = await constructAndStore('TextDecoderStream');220 const chunkPromise = readInReadRealm(objId);221 writeInWriteRealm(objId, new Uint8Array([65]));222 // Now the read() should resolve.223 const result = await chunkPromise;224 assert_equals(result.constructor, constructorRealm.Object,225 'result should be in constructor realm');226 // A string is not an object, so doesn't have an associated realm. Accessing227 // string properties will create a transient object wrapper belonging to the228 // current realm. So checking the realm of result.value is not useful.229 }, 'the result object when write is called with a pending ' +230 'read should come from the same realm as the constructor of TextDecoderStream');231 promise_test(async t => {232 const objId = await constructAndStore('TextDecoderStream');233 // Read first to relieve backpressure.234 const readPromise = readInReadRealm(objId);235 // promise_rejects() does not permit directly inspecting the rejection, so236 // it's necessary to write it out long-hand.237 let writeSucceeded = false;238 try {239 // Write an invalid chunk.240 await writeInWriteRealm(objId, {});241 writeSucceeded = true;242 } catch (err) {243 assert_equals(err.constructor, constructorRealm.TypeError,244 'write TypeError should come from constructor realm');245 }246 assert_false(writeSucceeded, 'write should fail');247 let readSucceeded = false;248 try {249 await readPromise;250 readSucceeded = true;251 } catch (err) {252 assert_equals(err.constructor, constructorRealm.TypeError,253 'read TypeError should come from constructor realm');254 }255 assert_false(readSucceeded, 'read should fail');256 }, 'TypeError for chunk with the wrong type should come from constructor ' +257 'realm of TextDecoderStream');258 promise_test(async t => {259 const objId =260 await constructAndStore(`TextDecoderStream('utf-8', {fatal: true})`);261 // Read first to relieve backpressure.262 const readPromise = readInReadRealm(objId);263 // promise_rejects() does not permit directly inspecting the rejection, so264 // it's necessary to write it out long-hand.265 let writeSucceeded = false;266 try {267 await writeInWriteRealm(objId, new Uint8Array([0xff]));268 writeSucceeded = true;269 } catch (err) {270 assert_equals(err.constructor, constructorRealm.TypeError,271 'write TypeError should come from constructor realm');272 }273 assert_false(writeSucceeded, 'write should fail');274 let readSucceeded = false;275 try {276 await readPromise;277 readSucceeded = true;278 } catch (err) {279 assert_equals(err.constructor, constructorRealm.TypeError,280 'read TypeError should come from constructor realm');281 }282 assert_false(readSucceeded, 'read should fail');283 }, 'TypeError for invalid chunk should come from constructor realm ' +284 'of TextDecoderStream');285 promise_test(async t => {286 const objId =287 await constructAndStore(`TextDecoderStream('utf-8', {fatal: true})`);288 // Read first to relieve backpressure.289 readInReadRealm(objId);290 // Write an unfinished sequence of bytes.291 const incompleteBytesId = id();292 writeRealm[incompleteBytesId] = new Uint8Array([0xf0]);293 // promise_rejects() does not permit directly inspecting the rejection, so294 // it's necessary to write it out long-hand.295 let closeSucceeded = false;296 try {297 // Can't use writeInWriteRealm() here because it doesn't make it possible298 // to reuse the writer.299 await evalInRealmAndReturn(writeRealm, `300(() => {301 const writer = window.${objId}.writable.getWriter();302 parent.writeMethod.call(writer, window.${incompleteBytesId});303 return parent.methodRealm.WritableStreamDefaultWriter.prototype304 .close.call(writer);305})();306`);307 closeSucceeded = true;308 } catch (err) {309 assert_equals(err.constructor, constructorRealm.TypeError,310 'close TypeError should come from constructor realm');311 }312 assert_false(closeSucceeded, 'close should fail');313 }, 'TypeError for incomplete input should come from constructor realm ' +314 'of TextDecoderStream');...

Full Screen

Full Screen

keycloak-realms.ts

Source:keycloak-realms.ts Github

copy

Full Screen

12import { NodeMessageInFlow, NodeMessage } from "node-red";3import { KeycloakConfig, mergeDeep, nodelog } from "./helper";4import KcAdminClient from 'keycloak-admin';5import axios, { AxiosRequestConfig, Method } from 'axios';6import RealmRepresentation from "keycloak-admin/lib/defs/realmRepresentation";7var debug = require('debug')('keycloak:realms')8export interface RealmMessage extends NodeMessageInFlow {9 payload: {10 execution_id: string;11 config: any;12 realm: any;13 }14}1516interface RealmPayload {17 realm?: RealmRepresentation,18 error?: any,19 created?: boolean,20 realms?: RealmRepresentation[]21}2223module.exports = function (RED: any) {2425 function getConfig(config: any, node: any, msg: any, input: KeycloakConfig): KeycloakConfig {26 const nodeConfig = {27 baseUrl: config.useenv ? process.env[config.baseUrlEnv] : config.baseUrl,28 realmName: input?.realmName || 'master',29 username: config?.credentials?.username,30 password: config?.credentials?.password,31 grantType: config?.grantType || 'password',32 clientId: config?.clientId || msg?.clientId || 'admin-cli',33 name: msg?.name || config?.name,34 action: msg?.action || node?.action || 'get',35 client: node?.clienttype !== 'json' ? msg?.payload?.client : JSON.parse(node?.client),36 realm: input?.realm37 } as KeycloakConfig;3839 return nodeConfig;40 }4142 function realmNode(config: any) {43 RED.nodes.createNode(this, config);44 let node = this;45 node.action = config.action;46 node.status({ text: `` })47 try {48 node.msg = {};49 node.on('input', (msg, send, done) => {50 let input: KeycloakConfig = {51 realm: RED.util.evaluateNodeProperty(config.realm, config.realmtype, node, msg),52 realmName: RED.util.evaluateNodeProperty(config.realmName, config.realmNametype, node, msg),53 }5455 send = send || function () { node.send.apply(node, arguments) }56 processInput(node, msg, send, done, config.confignode, input);57 });58 }59 catch (err) {60 node.error('Error: ' + err.message);61 node.status({ fill: "red", shape: "ring", text: err.message })62 nodelog({63 debug,64 action: "error",65 message: err.message, item: err, realm: ''66 })67 }68 }6970 async function processInput(node, msg: RealmMessage, send: (msg: NodeMessage | NodeMessage[]) => void, done: (err?: Error) => void, config, input: KeycloakConfig) {71 let configNode = RED.nodes.getNode(config);72 let kcAdminClient = await configNode.getKcAdminClient() as KcAdminClient;73 let kcConfig = getConfig(configNode, node, msg, input)74 let payload: RealmPayload | any = {7576 };77 try {78 if (!kcConfig.action || kcConfig.action === 'get') {79 payload.realms = await kcAdminClient.realms.find();80 }81 else if (kcConfig.action === 'create') {82 //@ts-ignore83 if (kcConfig.realmName) {84 //@ts-ignore85 kcConfig.realm.realm = kcConfig.realmName;86 }8788 try {89 let oldRealm = await kcAdminClient.realms.findOne({ realm: kcConfig.realm.realm });90 if (!oldRealm) {91 if (msg?.payload?.realm) {92 kcConfig.realm = mergeDeep(kcConfig.realm || {}, msg.payload.realm)93 }94 let newRealm = await kcAdminClient.realms.create(kcConfig.realm)95 payload.realm = await kcAdminClient.realms.findOne({ realm: kcConfig.realm.realm });96 node.status({ shape: 'dot', fill: 'green', text: `${kcConfig.realmName ? kcConfig.realmName : kcConfig.realm.realm} created` })97 nodelog({98 debug,99 action: "create",100 message: "created",101 item: kcConfig.realmName ? kcConfig.realmName : kcConfig.realm, realm: kcConfig.realmName ? kcConfig.realmName : kcConfig.realm.realm102 })103 } else {104 payload.realm = oldRealm;105 node.status({ shape: 'dot', fill: 'yellow', text: `${kcConfig.realmName ? kcConfig.realmName : kcConfig.realm.realm} already exists` })106 nodelog({107 debug,108 action: "create",109 message: "already exists",110 item: kcConfig.realmName ? kcConfig.realmName : kcConfig.realm, realm: kcConfig.realmName ? kcConfig.realmName : kcConfig.realm.realm111112 })113 }114 } catch (err) {115 payload.realm = await kcAdminClient.realms.findOne({ realm: kcConfig.realm.realm });116 node.status({ shape: 'dot', fill: 'yellow', text: `${kcConfig.realmName ? kcConfig.realmName : kcConfig.realm.realm} already exists` })117 nodelog({118 debug,119 action: "create",120 message: "already exists",121 item: kcConfig.realmName ? kcConfig.realmName : kcConfig.realm, realm: kcConfig.realmName ? kcConfig.realmName : kcConfig.realm.realm122 })123 }124 }125 else if (kcConfig.action === 'update') {126 //@ts-ignore127 if (kcConfig.realmName) {128 //@ts-ignore129 kcConfig.realm.realm = kcConfig.realmName;130 }131132 try {133 await kcAdminClient.realms.update({ realm: kcConfig.realm.realm }, kcConfig.realm)134 payload.realm = await kcAdminClient.realms.findOne({ realm: kcConfig.realm.realm });135 node.status({ shape: 'dot', fill: 'yellow', text: `${kcConfig.realmName ? kcConfig.realmName : kcConfig.realm.realm} already exists` })136 nodelog({137 debug,138 action: "update",139 message: "updated",140 item: kcConfig.realmName ? kcConfig.realmName : kcConfig.realm, realm: kcConfig.realmName ? kcConfig.realmName : kcConfig.realm.realm141 })142 } catch (err) {143 payload.realm = await kcAdminClient.realms.findOne({ realm: kcConfig.realm.realm });144 node.status({ shape: 'dot', fill: 'yellow', text: `${kcConfig.realmName ? kcConfig.realmName : kcConfig.realm.realm} already exists` })145 nodelog({146 debug,147 action: "create",148 message: "already exists",149 item: kcConfig.realmName ? kcConfig.realmName : kcConfig.realm, realm: kcConfig.realmName ? kcConfig.realmName : kcConfig.realm.realm150 })151 }152 }153 else if (kcConfig.action === 'getExecutions') {154 kcAdminClient.setConfig({155 realmName: kcConfig.realmName,156 });157 let executions = await kcAdminClient.authenticationManagement.getExecutions({ flow: 'browser' })158 payload = executions159 } else if (kcConfig.action === 'updateExecutionConfig') {160 let token = await kcAdminClient.getAccessToken()161 await axios({162 baseURL: `${kcConfig.baseUrl}/admin/realms/${kcConfig.realmName}/authentication/executions/${msg.payload.execution_id}/config`,163 headers: { 'Authorization': `Bearer ${token}` },164 method: 'PUT',165 data: msg.payload.config166 })167 node.status({ shape: 'dot', fill: 'green', text: `${msg.payload.execution_id} updated` })168169 } else if (kcConfig.action === 'clearRealmCache') {170 let token = await kcAdminClient.getAccessToken()171 await axios({172 baseURL: `${kcConfig.baseUrl}/admin/realms/${kcConfig.realmName}/clear-realm-cache`,173 headers: { 'Authorization': `Bearer ${token}` },174 method: 'POST'175 })176 node.status({ shape: 'dot', fill: 'green', text: `${kcConfig.realmName} clear-realm-cache` })177 }178179 let newMsg = Object.assign(RED.util.cloneMessage(msg), {180 payload: payload,181 realm: kcConfig.realmName182 });183184 send(newMsg)185 if (done) done();186 } catch (err) {187 node.status({ shape: 'dot', fill: 'red', text: `${err}` })188 if (done) done(err);189190 }191 setTimeout(() => node.status({ text: `` }), 10000)192 }193194 RED.nodes.registerType("keycloak-realms", realmNode); ...

Full Screen

Full Screen

cross-realm-filtering.js

Source:cross-realm-filtering.js Github

copy

Full Screen

1// Copyright 2014 the V8 project authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4var realms = [Realm.current(), Realm.create()];5// Check stack trace filtering across security contexts.6var thrower_script =7 "(function () { Realm.eval(Realm.current(), 'throw Error()') })";8Realm.shared = {9 thrower_0: Realm.eval(realms[0], thrower_script),10 thrower_1: Realm.eval(realms[1], thrower_script),11};12var script = " \13 Error.prepareStackTrace = function(a, b) { return b; }; \14 try { \15 Realm.shared.thrower_0(); \16 } catch (e) { \17 Realm.shared.error_0 = e.stack; \18 } \19 try { \20 Realm.shared.thrower_1(); \21 } catch (e) { \22 Realm.shared.error_1 = e.stack; \23 } \24";25function assertNotIn(thrower, error) {26 for (var i = 0; i < error.length; i++) {27 assertFalse(false === error[i].getFunction());28 }29}30Realm.eval(realms[1], script);31assertSame(2, Realm.shared.error_0.length);32assertSame(3, Realm.shared.error_1.length);33assertTrue(Realm.shared.thrower_1 === Realm.shared.error_1[1].getFunction());34assertNotIn(Realm.shared.thrower_0, Realm.shared.error_0);35assertNotIn(Realm.shared.thrower_0, Realm.shared.error_1);36Realm.eval(realms[0], script);37assertSame(4, Realm.shared.error_0.length);38assertSame(3, Realm.shared.error_1.length);39assertTrue(Realm.shared.thrower_0 === Realm.shared.error_0[1].getFunction());40assertNotIn(Realm.shared.thrower_1, Realm.shared.error_0);41assertNotIn(Realm.shared.thrower_1, Realm.shared.error_1);42// Check .caller filtering across security contexts.43var caller_script = "(function (f) { f(); })";44Realm.shared = {45 caller_0 : Realm.eval(realms[0], caller_script),46 caller_1 : Realm.eval(realms[1], caller_script),47}48script = " \49 function f_0() { Realm.shared.result_0 = arguments.callee.caller; }; \50 function f_1() { Realm.shared.result_1 = arguments.callee.caller; }; \51 Realm.shared.caller_0(f_0); \52 Realm.shared.caller_1(f_1); \53";54Realm.eval(realms[1], script);55assertSame(null, Realm.shared.result_0);56assertSame(Realm.shared.caller_1, Realm.shared.result_1);57Realm.eval(realms[0], script);58assertSame(Realm.shared.caller_0, Realm.shared.result_0);59assertSame(null, Realm.shared.result_1);60// test that do not pollute / leak a function prototype v8/421761var realmIndex = Realm.create();62var otherObject = Realm.eval(realmIndex, "Object");63var f = Realm.eval(realmIndex, "function f(){}; f");64f.prototype = null;65var o = new f();66var proto = Object.getPrototypeOf(o);67assertFalse(proto === Object.prototype);68assertTrue(proto === otherObject.prototype);69o = Realm.eval(realmIndex, "new f()");70proto = Object.getPrototypeOf(o);71assertFalse(proto === Object.prototype);72assertTrue(proto === otherObject.prototype);73// Check function constructor.74var ctor_script = "Function";75var ctor_a_script =76 "(function() { return Function.apply(this, ['return 1;']); })";77var ctor_b_script = "Function.bind(this, 'return 1;')";78var ctor_c_script =79 "(function() { return Function.call(this, 'return 1;'); })";80// Also check Promise constructor.81var promise_ctor_script = "Promise";82Realm.shared = {83 ctor_0 : Realm.eval(realms[0], ctor_script),84 ctor_1 : Realm.eval(realms[1], ctor_script),85 ctor_a_0 : Realm.eval(realms[0], ctor_a_script),86 ctor_a_1 : Realm.eval(realms[1], ctor_a_script),87 ctor_b_0 : Realm.eval(realms[0], ctor_b_script),88 ctor_b_1 : Realm.eval(realms[1], ctor_b_script),89 ctor_c_0 : Realm.eval(realms[0], ctor_c_script),90 ctor_c_1 : Realm.eval(realms[1], ctor_c_script),91 promise_ctor_0 : Realm.eval(realms[0], promise_ctor_script),92 promise_ctor_1 : Realm.eval(realms[1], promise_ctor_script),93}94var script_0 = " \95 var ctor_0 = Realm.shared.ctor_0; \96 var promise_ctor_0 = Realm.shared.promise_ctor_0; \97 Realm.shared.direct_0 = ctor_0('return 1'); \98 Realm.shared.indirect_0 = (function() { return ctor_0('return 1;'); })(); \99 Realm.shared.apply_0 = ctor_0.apply(this, ['return 1']); \100 Realm.shared.bind_0 = ctor_0.bind(this, 'return 1')(); \101 Realm.shared.call_0 = ctor_0.call(this, 'return 1'); \102 Realm.shared.proxy_0 = new Proxy(ctor_0, {})('return 1'); \103 Realm.shared.reflect_0 = Reflect.apply(ctor_0, this, ['return 1']); \104 Realm.shared.a_0 = Realm.shared.ctor_a_0(); \105 Realm.shared.b_0 = Realm.shared.ctor_b_0(); \106 Realm.shared.c_0 = Realm.shared.ctor_c_0(); \107 Realm.shared.p_0 = new promise_ctor_0((res,rej) => res(1)); \108";109script = script_0 + script_0.replace(/_0/g, "_1");110Realm.eval(realms[0], script);111assertSame(1, Realm.shared.direct_0());112assertSame(1, Realm.shared.indirect_0());113assertSame(1, Realm.shared.apply_0());114assertSame(1, Realm.shared.bind_0());115assertSame(1, Realm.shared.call_0());116assertSame(1, Realm.shared.proxy_0());117assertSame(1, Realm.shared.reflect_0());118assertSame(1, Realm.shared.a_0());119assertSame(1, Realm.shared.b_0());120assertSame(1, Realm.shared.c_0());121assertInstanceof(Realm.shared.p_0, Realm.shared.promise_ctor_0);122assertSame(undefined, Realm.shared.direct_1);123assertSame(undefined, Realm.shared.indirect_1);124assertSame(undefined, Realm.shared.apply_1);125assertSame(undefined, Realm.shared.bind_1);126assertSame(undefined, Realm.shared.call_1);127assertSame(undefined, Realm.shared.proxy_1);128assertSame(undefined, Realm.shared.reflect_1);129assertSame(undefined, Realm.shared.a_1);130assertSame(undefined, Realm.shared.b_1);131assertSame(undefined, Realm.shared.c_1);132assertSame(undefined, Realm.shared.p_1);133Realm.eval(realms[1], script);134assertSame(undefined, Realm.shared.direct_0);135assertSame(undefined, Realm.shared.indirect_0);136assertSame(undefined, Realm.shared.apply_0);137assertSame(undefined, Realm.shared.bind_0);138assertSame(undefined, Realm.shared.call_0);139assertSame(undefined, Realm.shared.proxy_0);140assertSame(undefined, Realm.shared.reflect_0);141assertSame(undefined, Realm.shared.a_0);142assertSame(undefined, Realm.shared.b_0);143assertSame(undefined, Realm.shared.c_0);144assertSame(undefined, Realm.shared.p_0);145assertSame(1, Realm.shared.direct_1());146assertSame(1, Realm.shared.indirect_1());147assertSame(1, Realm.shared.apply_1());148assertSame(1, Realm.shared.bind_1());149assertSame(1, Realm.shared.call_1());150assertSame(1, Realm.shared.proxy_1());151assertSame(1, Realm.shared.reflect_1());152assertSame(1, Realm.shared.a_1());153assertSame(1, Realm.shared.b_1());154assertSame(1, Realm.shared.c_1());...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var realm = wpt.realm();2realm.eval("console.log('Hello world');");3var realm = wpt.realm();4realm.eval("console.log('Hello world');");5The realm object returned from the realm() method has the following methods:6eval()7The eval() method returns a promise that is resolved with the result of the code executed in the realm. If the code executed in the realm throws

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var realm = wptools.realm('Sri Lanka');3realm.then(function(page) {4 console.log(page);5});6var realm = require('realm');7var wptools = realm.wptools('Sri Lanka');8wptools.then(function(page) {9 console.log(page);10});11var realm = require('realm');12var wptools = realm.wptools('Sri Lanka');13wptools.then(function(page) {14 console.log(page);15});16var realm = require('realm');17var wptools = realm.wptools('Sri Lanka');18wptools.then(function(page) {19 console.log(page);20});21var realm = require('realm');22var wptools = realm.wptools('Sri Lanka');23wptools.then(function(page) {24 console.log(page);25});26var realm = require('realm');27var wptools = realm.wptools('Sri Lanka');28wptools.then(function(page) {29 console.log(page);30});31var realm = require('realm');32var wptools = realm.wptools('Sri Lanka');33wptools.then(function(page) {34 console.log(page);35});36var realm = require('realm');37var wptools = realm.wptools('Sri Lanka');38wptools.then(function(page) {39 console.log(page);40});41var realm = require('realm');42var wptools = realm.wptools('Sri Lanka');43wptools.then(function(page) {44 console.log(page);45});46var realm = require('realm');47var wptools = realm.wptools('Sri Lanka');48wptools.then(function(page) {49 console.log(page);50});51var realm = require('realm');52var wptools = realm.wptools('Sri Lanka');53wptools.then(function(page) {54 console.log(page);55});

Full Screen

Using AI Code Generation

copy

Full Screen

1var realm = $ENV.REALM;2var realm = $ENV.REALM;3if (realm == "wpt") {4 var realm = "wpt";5} else {6 var realm = "local";7}8var realm = $ENV.REALM;9if (realm == "wpt") {10 var realm = "wpt";11} else {12 var realm = "local";13}14var realm = $ENV.REALM;15if (realm == "wpt") {16 var realm = "wpt";17} else {18 var realm = "local";19}20var realm = $ENV.REALM;21if (realm == "wpt") {22 var realm = "wpt";23} else {24 var realm = "local";25}26var realm = $ENV.REALM;27if (realm == "wpt") {28 var realm = "wpt";29} else {30 var realm = "local";31}32var realm = $ENV.REALM;33if (realm == "wpt") {34 var realm = "wpt";35} else {36 var realm = "local";37}38var realm = $ENV.REALM;39if (realm == "wpt") {40 var realm = "wpt";41} else {42 var realm = "local";43}44var realm = $ENV.REALM;45if (realm == "wpt") {46 var realm = "wpt";47} else {48 var realm = "local";49}50var realm = $ENV.REALM;51if (realm == "wpt") {52 var realm = "wpt";53} else {54 var realm = "local";55}56var realm = $ENV.REALM;57if (realm == "wpt") {58 var realm = "wpt";59} else {60 var realm = "local";61}62var realm = $ENV.REALM;63if (realm == "wpt") {

Full Screen

Using AI Code Generation

copy

Full Screen

1var realm = new Realm();2realm.eval("console.log('hello world')");3var realm = new WorkerGlobalScope().realm;4realm.eval("console.log('hello world')");5var realm = this.realm;6realm.eval("console.log('hello world')");7var realm = this;8realm.eval("console.log('hello world')");9var realm = this;10realm.eval("console.log('hello world')");11var realm = this;12realm.eval("console.log('hello world')");13var realm = this;14realm.eval("console.log('hello world')");15var realm = this;16realm.eval("console.log('hello world')");

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var realm = require('realm');3var test = wpt('myKey');4var myRealm = realm('myRealm');5 if (err) {6 console.log(err);7 } else {8 console.log(data);9 myRealm.write(data);10 }11});12test.getTestResults('140313_6X_3e0f4e4a7d0a8a7b7c1f1d4a0c8e0f1a', function(err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 myRealm.write(data);18 }19});20test.getTestResults('140313_6X_3e0f4e4a7d0a8a7b7c1f1d4a0c8e0f1a', 'Dulles:Chrome', function(err, data) {21 if (err) {22 console.log(err);23 } else {24 console.log(data);25 myRealm.write(data);26 }27});28test.getTestResults('140313_6X_3e0f4e4a7d0a8a7b7c1f1d4a0c8e0f1a', 'Dulles:Chrome', 'xml', function(err, data) {29 if (err) {30 console.log(err);31 } else {32 console.log(data);33 myRealm.write(data);34 }35});36test.getTestResults('140313_6X_3e0f4e4a7d0a8a7b7c1f1d4a0c8e0f1a', 'Dulles:Chrome', 'json', function(err, data) {37 if (err) {38 console.log(err);39 } else {40 console.log(data);41 myRealm.write(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