Skip to content

Instantly share code, notes, and snippets.

View benjamingr's full-sized avatar
🖊️
Limited availability.

Benjamin Gruenbaum benjamingr

🖊️
Limited availability.
View GitHub Profile
'use strict';
const { withToken, token } = require('./token.js');
const { setTimeout } = require('timers/promises');
const controller = withToken(() => {
flow();
});
setTimeout(100).then(() => {
console.log('aborting');
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
FFBBBFBLRL
BFFFBFBRRR
BFFFBFBLRL
BFFBFBBLRR
BBFFBFFRLL
BFFFBFBRLR
FFFFBBBRLR
BBFFFBBRRR
BBFBFBBRRR
BFFBBBFLRR
'use strict';
require('v8').setFlagsFromString('--allow-natives-syntax');
// Extracted from v8/src/runtime/runtime.h
const methodNames = [
"Abort",
"AbortJS",
"AbortCSAAssert",
"ArraySpeciesProtector",

Testim.io

Who am I

Hi, I'm Benji, I'm a developer @ Testim.io for the last year and a half. I was asked to write a little about how we work here at Testim.io. Other than that this is me on GitHub and Stack Overflow.

Developer Point of View.

Testim is an E2E functional test recording and playback tool. We automate the hard parts of end to end testing which are stability and fast authoring. In addition we provide a lot of useful root-cause analysis information for your tests.

// a non recursively assimilating promise without error recovery
class NonAssimilatingPromise<T, E> {
public value?: T;
constructor(value?: T, public error?: E) {
if (value) {
this.value = value;
}
}
then<T2, E2>(fn: (value: T) => NonAssimilatingPromise<T2, E2>): NonAssimilatingPromise<T2, E | E2> {
if (this.error) {
class Throws<T> {
constructor(public error?: T) {
}
then<S>(fn: () => Throws<S>): Throws<T | S> {
if (this.error) {
// already errored, don't attempt to run the next action
return this;
}
const result = fn();
@benjamingr
benjamingr / chrome_click.cc
Created April 16, 2019 15:06
What happens on a click
// actual differences (in chrome, IE, Firefox, Safari an Edge are all different) are:
// - behavior in disabled 'form' controls
// - phoning to home base (not here, it's defined elsewhere, can dig it up)
// - dealing with clicks dispatching clicks 'recursively'
// this is HTMLElement::click
void HTMLElement::click() {
DispatchSimulatedClick(nullptr, kSendNoEvents,
SimulatedClickCreationScope::kFromScript);
}
class Dispatch extends EventTarget {
dispatch(eventName) {
const ev = new Event(eventName);
if (("on" + eventName) in this) {
this["on" + eventName](ev);
}
this.dispatchEvent(ev);
}
}
class XMLHttpRequest extends Dispatch {
function interceptNetworkRequests(ee) {
const open = XMLHttpRequest.prototype.open;
const send = XMLHttpRequest.prototype.send;
const isRegularXHR = open.toString().indexOf('native code') !== -1;
// don't hijack if already hijacked - this will mess up with frameworks like Angular with zones
// we work if we load first there which we can.
if (isRegularXHR) {
function querySelectorAllDeep(root, selector) {
const [start, ...rest] = Array.isArray(selector) ? selector : selector.split(" /deep/ ");
if (rest.length === 0) return [...root.querySelectorAll(start)];
return [...root.querySelectorAll(start + " *")].map(x => x.shadowRoot).filter(Boolean).map(x => querySelectorAllDeep(x, rest)).flat();
}
function unshadowDOM(dom, tagnNameOverride) {
const root = document.createElement(tagnNameOverride || dom.tagName || "fragment");
for(const {name, value} of (dom.attributes || [])) {
try {