Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

min-wd

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

min-wd - npm Package Compare versions

Comparing version 2.9.0 to 2.9.1

17

CHANGES.md
# Changes
## 2.9.1
Running test suits or projects sometimes caused issues with Chrome. This appears
to be an issue with a buffer size limit when executing scripts through
`chromedriver`.
With this path, scripts are no longer injected directly. Instead, a small
receiver function is injected and the actual test code is sent to that function
in chunks, bypassing the buffer limit. Once the script was fully received by the
browser, it is injected with a new `<script>` tag.
Related issues:
- <https://github.com/mantoni/mochify.js/issues/110>
- <https://github.com/sinonjs/sinon/issues/912>
- <https://bugs.chromium.org/p/chromedriver/issues/detail?id=402>
## 2.9.0

@@ -4,0 +21,0 @@

101

lib/driver.js

@@ -25,2 +25,12 @@ /*

function handleError(context, err, callback) {
if (context.closeOnError) {
close(context, function () {
callback(err);
});
} else {
callback(err);
}
}
function pollLogs(context, callback) {

@@ -40,9 +50,3 @@ var endpoint = context.asyncPolling ? '/execute_async' : '/execute';

if (err) {
if (context.closeOnError) {
close(context, function () {
callback(err);
});
} else {
callback(err);
}
handleError(context, err, callback);
return;

@@ -97,22 +101,57 @@ }

/*
* This hack works around the following issues:
*
* https://github.com/mantoni/mochify.js/issues/110
* https://bugs.chromium.org/p/chromedriver/issues/detail?id=402
* https://github.com/sinonjs/sinon/issues/912
*
* Apparently the Chrome webdriver has a buffer limit somewhere around 1 MB.
* Injecting scripts that are below a certain size works reliably, so we have
* to slice the actual script into chunks, merge the parts in the browser and
* then inject a script tag there.
*/
var MAX_SCRIPT_CHUNK = 900 * 1000;
function streamChunk(context, script, callback) {
var execute = false;
var nextScript = '';
if (script.length > MAX_SCRIPT_CHUNK) {
nextScript = script.substring(MAX_SCRIPT_CHUNK);
script = script.substring(0, MAX_SCRIPT_CHUNK);
} else {
execute = true;
}
request(context, 'POST', '/execute', {
script: 'window._webdriver_receive(arguments[0], arguments[1])',
args: [script, execute]
}, function (err) {
if (err) {
handleError(context, err, callback);
} else if (nextScript) {
streamChunk(context, nextScript, callback);
} else {
setTimeout(function () {
pollLogs(context, callback);
}, 10);
}
});
}
function execute(context, script, callback) {
request(context, 'POST', '/execute', {
script : script,
args : []
script: 'var script = "";'
+ 'window._webdriver_receive = function (chunk, execute) {'
+ 'script += chunk;'
+ 'if (execute) {'
+ ' var s = document.createElement("script");'
+ ' s.textContent = script;'
+ ' document.body.appendChild(s);'
+ '}};',
args: []
}, function (err) {
if (err) {
if (context.closeOnError) {
close(context, function () {
callback(err);
});
} else {
callback(err);
}
return;
handleError(context, err, callback);
} else {
streamChunk(context, script, callback);
}
setTimeout(function () {
pollLogs(context, callback);
}, 10);
});

@@ -139,9 +178,3 @@ }

if (err) {
if (context.closeOnError) {
close(context, function () {
callback(err);
});
} else {
callback(err);
}
handleError(context, err, callback);
return;

@@ -184,9 +217,7 @@ }

}, function (err) {
if (err && context.closeOnError) {
close(context, function () {
callback(err);
});
return;
if (err) {
handleError(context, err, callback);
} else {
callback(null);
}
callback(null);
});

@@ -193,0 +224,0 @@ });

{
"name": "min-wd",
"version": "2.9.0",
"version": "2.9.1",
"description": "Minimal WebDriver that pipes stdin to browsers",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc