Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

Fix button.type = 'submit' and support button.type = 'reset' - Fix #1190 #1197

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ function setupWindow(window, args) {
window.FormData = Fetch.FormData;

// Base-64 encoding/decoding
window.atob = (string)=> new Buffer(string, 'base64').toString('binary');
window.btoa = (string)=> new Buffer(string, 'binary').toString('base64');
window.atob = (string)=> Buffer.from(string, 'base64').toString('binary');
window.btoa = (string)=> Buffer.from(string, 'binary').toString('base64');

// Constructor for XHLHttpRequest
window.XMLHttpRequest = XMLHttpRequest.bind(null, window);
Expand Down
12 changes: 11 additions & 1 deletion src/dom/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,19 @@ DOM.HTMLButtonElement.prototype._click = function(event) {
if (button.getAttribute('disabled'))
return false;

const buttonType = button.getAttribute('type');
if (buttonType === 'button')
return;

const form = button.form;
if (form)
if (form) {
if (buttonType === 'reset') {
input.form.reset();
return;
}

return form._dispatchSubmitEvent(button);
}
};

DOM.HTMLInputElement.prototype._click = function(event) {
Expand Down
2 changes: 1 addition & 1 deletion src/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class Body {
return null;
// When Response has no body, we get stream that's no longer readable
if (!this._stream.readable)
return new Buffer('');
return Buffer.from('');

const decompressed = decompressStream(this._stream, this.headers);

Expand Down
2 changes: 1 addition & 1 deletion src/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class Pipeline extends Array {
const { username, password } = authenticate;
if (username && password) {
browser.log(`Authenticating as ${username}:${password}`);
const base64 = new Buffer(`${username}:${password}`).toString('base64');
const base64 = Buffer.from(`${username}:${password}`).toString('base64');
request.headers.set('authorization', `Basic ${base64}`);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/websocket_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('WebSockets', function() {
});

it('should be possible', function() {
browser.assert.text('#ws-url', 'ws://example.com:3004');
browser.assert.text('#ws-url', 'ws://example.com:3004/');
});
it('should raise open event after connecting', function() {
assert.equal(prompts[0], 'open');
Expand Down