-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
323 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,4 +48,4 @@ <h5>native events</h5> | |
xhook.disable(); | ||
test("native"); | ||
|
||
</script> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `Add Event Listeners` | ||
.page `http://localhost:3000/#add-event-listener`; | ||
|
||
test('Should add event listeners to XHR', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#one').innerText).eql('thzs zs thz szcznd tzxt fzlz zxzmplz (zxzmplz2.txt)') | ||
.expect(Selector('#status').innerText).eql('loaded!!!'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `Angular` | ||
.page `http://localhost:3000/#angular`; | ||
|
||
test('example 1 response should not be modified', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#one').innerText).eql('this is the first text file example (example1.txt)'); | ||
}); | ||
|
||
test('example 2 response should be modified', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#two').innerText).eql('thzs zs thz szcznd tzxt fzlz zxzmplz (zxzmplz2.txt)'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `Case Insensitive Headers` | ||
.page `http://localhost:3000/#case-insensitive-headers`; | ||
|
||
test('response should include all header variations', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#result-1').innerText).contains('conTENT-type: text/plain; charset=UTF-8') | ||
.expect(Selector('#result-1').innerText).contains('CONTENt-TYPe: text/plain; charset=UTF-8') | ||
.expect(Selector('#result-1').innerText).contains('Content-Type: text/plain; charset=UTF-8'); | ||
}); | ||
|
||
test('response should include all values for foo-bar header', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#result-2').innerText).contains('"foO-BAR": "42, 21"'); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `Events` | ||
.page `http://localhost:3000/#events`; | ||
|
||
test('should complete with xhook events', async t => { | ||
const xhookResult = Selector('#xhook'); | ||
|
||
await t | ||
.switchToIframe('iframe') | ||
.wait(3000) // compensate for a real 3s delay from the echo server | ||
.expect(xhookResult.innerText).contains('[before start]...\n' + | ||
'[before end]\n' + | ||
'readystatechange (2)\n' + | ||
'readystatechange (3)\n' + | ||
'progress (3)\n' + | ||
'readystatechange (3)\n' + | ||
'readystatechange (4)\n' + | ||
'load (4)\n' + | ||
' => 200\n') | ||
.expect(xhookResult.innerText).contains('loadend (4)'); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `Fake download events` | ||
.page `http://localhost:3000/#progress-download-fake`; | ||
|
||
test('should complete with fake download events', async t => { | ||
const result = Selector('#events'); | ||
|
||
await t | ||
.switchToIframe('iframe') | ||
.expect(result.innerText).eql('readyState 1\n' + | ||
'0\n' + | ||
'readyState 2\n' + | ||
'readyState 3\n' + | ||
'13\n' + | ||
'readyState 3\n' + | ||
'26\n' + | ||
'readyState 3\n' + | ||
'39\n' + | ||
'readyState 3\n' + | ||
'52\n' + | ||
'readyState 3\n' + | ||
'65\n' + | ||
'readyState 3\n' + | ||
'78\n' + | ||
'readyState 3\n' + | ||
'91\n' + | ||
'readyState 3\n' + | ||
'100\n' + | ||
'readyState 3\n' + | ||
'readyState 4\n'); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `Fake Response` | ||
.page `http://localhost:3000/#fake-response`; | ||
|
||
test('XHR content should be modified', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#res').innerText).eql('this is the third text file example (example3.txt)'); | ||
}); | ||
|
||
test('fetch content should be modified', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#fetch_res').innerText).eql('this is the third text file example (example3.txt)'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `Fetch WebWorker` | ||
.page `http://localhost:3000/#fetch-webworker`; | ||
|
||
test('example 1 response should not be modified', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#one').innerText).eql('this is the first text file example (example1.txt)'); | ||
}); | ||
|
||
test('example 2 response should be modified', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#two').innerText).eql('thzs zs thz szcznd tzxt fzlz zxzmplz (zxzmplz2.txt)'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `Fetch` | ||
.page `http://localhost:3000/#vanilla-fetch`; | ||
|
||
test('example 1 response should not be modified', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#one').innerText).eql('this is the first text file example (example1.txt)'); | ||
}); | ||
|
||
test('example 2 response should be modified', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#two').innerText).eql('thzs zs thz szcznd tzxt fzlz zxzmplz (zxzmplz2.txt)'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `jQuery` | ||
.page `http://localhost:3000/#jquery`; | ||
|
||
test('example 1 response should not be modified', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#one').innerText).eql('this is the first text file example (example1.txt)'); | ||
}); | ||
|
||
test('example 2 response should be modified', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#two').innerText).eql('thzs zs thz szcznd tzxt fzlz zxzmplz (zxzmplz2.txt)'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `Modify Headers` | ||
.page `http://localhost:3000/#modify-headers`; | ||
|
||
test('response should include Foo Header', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#res').innerText).contains('foo:\tBar'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `Modify Method Url` | ||
.page `http://localhost:3000/#modify-method-url`; | ||
|
||
test('XHR should get example2.txt content', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#one').innerText).eql('this is the second text file example (example2.txt)'); | ||
}); | ||
|
||
test('Fetch should get example2.txt content', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#fetch_one').innerText).eql('this is the second text file example (example2.txt)'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `Real download events` | ||
.page `http://localhost:3000/#progress-download-real`; | ||
|
||
test('should complete with real download events', async t => { | ||
const result = Selector('#events'); | ||
|
||
await t | ||
.switchToIframe('iframe') | ||
.expect(result.innerText).contains('readyState 1\n' + | ||
'hooked xhr though left untouched!\n' + | ||
'readyState 2\n' + | ||
'readyState 3\n') | ||
.expect(result.innerText).contains( | ||
'readyState 3\n' + | ||
'100\n' + | ||
'readyState 3\n' + | ||
'readyState 4\n'); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `Real upload events` | ||
.page `http://localhost:3000/#progress-upload-real`; | ||
|
||
test('should complete with real upload events', async t => { | ||
const result = Selector('#events'); | ||
|
||
await t | ||
.switchToIframe('iframe') | ||
.expect(result.innerText).eql('readyState 1\n' + | ||
'sending #288889 chars\n' + | ||
'hooked xhr though left untouched!\n' + | ||
'upload started\n' + | ||
'100\n' + | ||
'upload complete\n' + | ||
'readyState 2\n' + | ||
'readyState 3\n' + | ||
'readyState 4\n'); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `Track Errors` | ||
.page `http://localhost:3000/#track-errors`; | ||
|
||
test('Should detect XHR & fetch errors', async t => { | ||
const result = Selector('pre'); | ||
|
||
await t | ||
.switchToIframe('iframe') | ||
.expect(result.innerText).contains('(1) Non-200 error code detected: 404') | ||
.expect(result.innerText).contains('(2) Non-200 error code detected: 404'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `Vanilla` | ||
.page `http://localhost:3000/#vanilla`; | ||
|
||
test('example 1 response should not be modified', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#one').innerText).eql('this is the first text file example (example1.txt)'); | ||
}); | ||
|
||
test('example 2 response should be modified', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#two').innerText).eql('thzs zs thz szcznd tzxt fzlz zxzmplz (zxzmplz2.txt)'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
fixture `XHR Reuse` | ||
.page `http://localhost:3000/#xhr-reuse`; | ||
|
||
test('example 1 should return example1.txt', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#one').innerText).eql('this is the first text file example (example1.txt)'); | ||
}); | ||
|
||
test('example 2 should return example2.txt', async t => { | ||
await t | ||
.switchToIframe('iframe') | ||
.expect(Selector('#two').innerText).eql('this is the second text file example (example2.txt)'); | ||
}); |
Oops, something went wrong.
4be845b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍