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
1 parent
fd2fa14
commit f49b641
Showing
4 changed files
with
88 additions
and
2 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
language: node_js | |||
node_js: | |||
- "8.1.3" | |||
cache: | |||
directories: | |||
- node_modules | |||
install: | |||
- npm install | |||
script: | |||
- npm run lint | |||
- npm run test |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,27 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> | |||
<meta charset="utf-8" /> | |||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |||
<title>live-torrent demo</title> | |||
</head> | |||
|
|||
<body> <h1>Tests</h1> </body> | |||
|
|||
<script src="./build.js"></script> | |||
<script> | |||
const chunksDone = {} | |||
|
|||
const dlManifest = async () => { | |||
const m = await fetch('manifest.m3u8') | |||
const t = await m.text() | |||
const last = t.split('\n').filter(l => l.includes('http://'))[2] | |||
if (chunksDone[last]) return | |||
chunksDone[last] = true | |||
fetch(last) | |||
} | |||
|
|||
dlManifest() | |||
setInterval(dlManifest, 2000) | |||
</script> | |||
</html> |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,43 @@ | |||
const puppeteer = require('puppeteer') | |||
const test = require('tape') | |||
|
|||
const url = 'http://127.0.0.1:8008/fake-video.html' | |||
|
|||
const sleep = t => new Promise(resolve => setTimeout(resolve, t)) | |||
|
|||
async function testp2p (t) { | |||
t.plan(1) | |||
|
|||
// Spawn first chrome | |||
const browser1 = await puppeteer.launch({ headless: true, args: ['--no-sandbox'] }) | |||
const page1 = await browser1.newPage() | |||
await page1.goto(url) | |||
await sleep(6000) | |||
|
|||
// Spawn second chrome | |||
const browser2 = await puppeteer.launch({ headless: true, args: ['--no-sandbox'] }) | |||
const page2 = await browser2.newPage() | |||
|
|||
let p2p = false | |||
page2.on('console', msg => { | |||
console.log(msg.text()) | |||
p2p = msg.text().includes('P2P Download') || msg.text().includes('P2P Upload') ? true : p2p | |||
}) | |||
|
|||
await page2.goto(url) | |||
await sleep(30000) | |||
|
|||
// Cleanup | |||
await browser1.close() | |||
await browser2.close() | |||
|
|||
console.log(' ') | |||
t.true(p2p, 'browsers exchanged content between each-others 👏') | |||
t.end() | |||
} | |||
|
|||
const doTest = async () => { | |||
test('Test p2p between 2 browsers\n', testp2p) | |||
} | |||
|
|||
doTest() |