Skip to content

Commit

Permalink
Merge pull request #133 from Seneca-CDOT/revert-132-issues/107-newlin…
Browse files Browse the repository at this point in the history
…e-error

Revert "fix: correct returning newlines in execute script sync"
  • Loading branch information
poftadeh authored Jan 16, 2020
2 parents 6a77936 + b1fdd00 commit 65637b5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
5 changes: 1 addition & 4 deletions src/Session/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,12 +690,9 @@ class Session {
});

const { window } = this.browser.dom;
const scriptWithEscapedNewlines = script
.replace(/\r\n/g, '\\r\\n')
.replace(/\n/g, '\\n');

const func = window
.eval(`(function() {${scriptWithEscapedNewlines}})`)
.eval(`(function() {${script}})`)
.bind(null, ...argumentList);

const vm = new VM({
Expand Down
6 changes: 0 additions & 6 deletions test/jest/e2e/execute-script-sync.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,4 @@ describe('Execute Script Sync', () => {
await executeScript('return document.getElementsByTagName("body")'),
).toStrictEqual([{ [ELEMENT]: expect.any(String) }]);
});

it('handles returning newlines', async () => {
expect(await executeScript('return "\n"')).toBe('\n');
expect(await executeScript('return "\r\n"')).toBe('\r\n');
expect(await executeScript('return "\n\r\n\r\n";')).toBe('\n\r\n\r\n');
});
});

0 comments on commit 65637b5

Please sign in to comment.