Skip to content

Commit 7849aa4

Browse files
committed
fixed conflict
2 parents 4873696 + d03468a commit 7849aa4

9 files changed

Lines changed: 198 additions & 2 deletions

File tree

lib/webpagetest.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ var paths = {
2929
waterfall: 'waterfall.php',
3030
thumbnail: 'thumbnail.php',
3131
cancel: 'cancelTest.php',
32-
history: 'testlog.php'
32+
history: 'testlog.php',
33+
videoCreation: 'video/create.php',
34+
videoView: 'video/view.php'
3335
};
3436

3537
var filenames = {
@@ -601,6 +603,35 @@ function listen(local, callback) {
601603
return server.listen.call(this, local, callback);
602604
}
603605

606+
function getEmbedVideoPlayer(id, options, callback) {
607+
var params = {
608+
embed: 1,
609+
id: id
610+
};
611+
612+
options.args = options.args || {
613+
type: 'text/html',
614+
encoding: options.dataURI ? 'utf8' : options.encoding
615+
};
616+
617+
options.parser = function (data) {
618+
return data.toString();
619+
};
620+
621+
api.call(this, paths.videoView, callback, params, options);
622+
}
623+
624+
function createVideo(tests, options, callback) {
625+
//prefer the json format because the xml format is buggy with wpt 2.11
626+
var params = {
627+
tests: tests,
628+
f: 'json',
629+
end: options.end || 'visual'
630+
};
631+
632+
api.call(this, paths.videoCreation, callback, params, options);
633+
}
634+
604635
// WPT constructor
605636
function WebPageTest(server, key) {
606637
if (!(this instanceof WebPageTest)) {
@@ -645,6 +676,8 @@ WebPageTest.prototype = {
645676
getHistory: getHistory,
646677
getWaterfallImage: getWaterfallImage,
647678
getScreenshotImage: getScreenshotImage,
679+
getEmbedVideoPlayer: getEmbedVideoPlayer,
680+
createVideo: createVideo,
648681
scriptToString: WebPageTest.scriptToString,
649682
listen: listen,
650683

test/dryrun-test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,5 +364,20 @@ describe('Dry Run', function() {
364364
});
365365
});
366366

367+
it('create a video', function (done) {
368+
wpt.createVideo('130416_YS_KD4-r:3-c:1,130416_W6_KEE-r:8-c:1', {dryRun: true}, function (err, data) {
369+
if (err) throw err;
370+
assert.equal(data.url, wptServer + 'video/create.php?tests=130416_YS_KD4-r%3A3-c%3A1%2C130416_W6_KEE-r%3A8-c%3A1&f=json&end=visual');
371+
done();
372+
});
373+
});
374+
375+
it('get the url of an embedded video', function (done) {
376+
wpt.getEmbedVideoPlayer('130416_36ed6e37013655a14b2b857cdccec99db72adcaa', {dryRun: true}, function (err, data) {
377+
if (err) throw err;
378+
assert.equal(data.url, wptServer + 'video/view.php?embed=1&id=130416_36ed6e37013655a14b2b857cdccec99db72adcaa');
379+
done();
380+
});
381+
});
367382
});
368383
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"statusCode":200,
3+
"statusText":"Ok",
4+
"data":{
5+
"videoId":"130416_36ed6e37013655a14b2b857cdccec99db72adcaa",
6+
"jsonUrl":"http:\/\/www.webpagetest.org\/video\/view.php?f=json&id=130416_36ed6e37013655a14b2b857cdccec99db72adcaa",
7+
"userUrl":"http:\/\/www.webpagetest.org\/video\/view.php?id=130416_36ed6e37013655a14b2b857cdccec99db72adcaa"
8+
}
9+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script>
5+
<title>WebPagetest - Visual Comparison - Apr 30, 2013 : , </title>
6+
<link rel="stylesheet" href="/video/video-js.3.2.0/video-js.min.css" type="text/css">
7+
<style type="text/css">
8+
div.content
9+
{
10+
text-align:center;
11+
background-color: black;
12+
color: white;
13+
font-family: arial,sans-serif
14+
}
15+
.link
16+
{
17+
text-decoration: none;
18+
color: white;
19+
}
20+
#player
21+
{
22+
margin-left: auto;
23+
margin-right: auto;
24+
}
25+
#location {
26+
text-align: left;
27+
padding: 5px;
28+
width: 100%;
29+
}
30+
.vjs-default-skin .vjs-controls {height: 0;}
31+
.vjs-default-skin .vjs-mute-control {display: none;}
32+
.vjs-default-skin .vjs-volume-control {display: none;}
33+
body {background-color: black; margin:0; padding: 0;} </style>
34+
<script type="text/javascript" src="/video/video-js.3.2.0/video.min.js"></script>
35+
</head>
36+
<body>
37+
<div class="page">
38+
<script>
39+
_V_.options.techOrder = ['flash', 'html5'];
40+
_V_.options.flash.swf = '/video/player/flowplayer-3.2.16.swf';
41+
_V_.options.flash.flashVars = {config:"{'clip':{'scaling':'fit'},'plugins':{'controls':{'volume':false,'mute':false,'stop':true,'tooltips':{'buttons':true,'fullscreen':'Enter fullscreen mode'}}},'canvas':{'backgroundColor':'#000000','backgroundGradient':'none'},'playlist':[{'url':'/results/video/13/04/16/36ed6e37013655a14b2b857cdccec99db72adcaa/video.png'},{'url':'/results/video/13/04/16/36ed6e37013655a14b2b857cdccec99db72adcaa/video.mp4','autoPlay':false,'autoBuffering':false}]}"};
42+
_V_.options.flash.params = {
43+
allowfullscreen: 'true',
44+
wmode: 'transparent',
45+
allowscriptaccess: 'always'
46+
};
47+
_V_.options.flash.attributes={};
48+
</script>
49+
<video id="player" class="video-js vjs-default-skin" controls
50+
preload="auto" width="816" height="384" poster="/results/video/13/04/16/36ed6e37013655a14b2b857cdccec99db72adcaa/video.png"data-setup="{}">
51+
<source src="/results/video/13/04/16/36ed6e37013655a14b2b857cdccec99db72adcaa/video.mp4" type='video/mp4'>
52+
</video>
53+
</div>
54+
<script type="text/javascript">if(!NREUMQ.f){NREUMQ.f=function(){NREUMQ.push(["load",new Date().getTime()]);var e=document.createElement("script");e.type="text/javascript";e.src=(("http:"===document.location.protocol)?"http:":"https:")+"//"+"d1ros97qkrwjf5.cloudfront.net/42/eum/rum.js";document.body.appendChild(e);if(NREUMQ.a)NREUMQ.a();};NREUMQ.a=window.onload;window.onload=NREUMQ.f;};NREUMQ.push(["nrfj","beacon-1.newrelic.com","5b0327a758","2035125","NFBXZUNRW0ADAkRbCQ0aYENYH0NaBgRfHRAKUEIfQVhF",0,5,new Date().getTime(),"","","","",""]);</script>
55+
</body>
56+
</html>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"statusCode":200,
3+
"statusText":"Ok",
4+
"data":{
5+
"videoId":"130416_36ed6e37013655a14b2b857cdccec99db72adcaa",
6+
"jsonUrl":"http:\/\/www.webpagetest.org\/video\/view.php?f=json&id=130416_36ed6e37013655a14b2b857cdccec99db72adcaa",
7+
"userUrl":"http:\/\/www.webpagetest.org\/video\/view.php?id=130416_36ed6e37013655a14b2b857cdccec99db72adcaa"
8+
}
9+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script>
5+
<title>WebPagetest - Visual Comparison - Apr 30, 2013 : , </title>
6+
<link rel="stylesheet" href="/video/video-js.3.2.0/video-js.min.css" type="text/css">
7+
<style type="text/css">
8+
div.content
9+
{
10+
text-align:center;
11+
background-color: black;
12+
color: white;
13+
font-family: arial,sans-serif
14+
}
15+
.link
16+
{
17+
text-decoration: none;
18+
color: white;
19+
}
20+
#player
21+
{
22+
margin-left: auto;
23+
margin-right: auto;
24+
}
25+
#location {
26+
text-align: left;
27+
padding: 5px;
28+
width: 100%;
29+
}
30+
.vjs-default-skin .vjs-controls {height: 0;}
31+
.vjs-default-skin .vjs-mute-control {display: none;}
32+
.vjs-default-skin .vjs-volume-control {display: none;}
33+
body {background-color: black; margin:0; padding: 0;} </style>
34+
<script type="text/javascript" src="/video/video-js.3.2.0/video.min.js"></script>
35+
</head>
36+
<body>
37+
<div class="page">
38+
<script>
39+
_V_.options.techOrder = ['flash', 'html5'];
40+
_V_.options.flash.swf = '/video/player/flowplayer-3.2.16.swf';
41+
_V_.options.flash.flashVars = {config:"{'clip':{'scaling':'fit'},'plugins':{'controls':{'volume':false,'mute':false,'stop':true,'tooltips':{'buttons':true,'fullscreen':'Enter fullscreen mode'}}},'canvas':{'backgroundColor':'#000000','backgroundGradient':'none'},'playlist':[{'url':'/results/video/13/04/16/36ed6e37013655a14b2b857cdccec99db72adcaa/video.png'},{'url':'/results/video/13/04/16/36ed6e37013655a14b2b857cdccec99db72adcaa/video.mp4','autoPlay':false,'autoBuffering':false}]}"};
42+
_V_.options.flash.params = {
43+
allowfullscreen: 'true',
44+
wmode: 'transparent',
45+
allowscriptaccess: 'always'
46+
};
47+
_V_.options.flash.attributes={};
48+
</script>
49+
<video id="player" class="video-js vjs-default-skin" controls
50+
preload="auto" width="816" height="384" poster="/results/video/13/04/16/36ed6e37013655a14b2b857cdccec99db72adcaa/video.png"data-setup="{}">
51+
<source src="/results/video/13/04/16/36ed6e37013655a14b2b857cdccec99db72adcaa/video.mp4" type='video/mp4'>
52+
</video>
53+
</div>
54+
<script type="text/javascript">if(!NREUMQ.f){NREUMQ.f=function(){NREUMQ.push(["load",new Date().getTime()]);var e=document.createElement("script");e.type="text/javascript";e.src=(("http:"===document.location.protocol)?"http:":"https:")+"//"+"d1ros97qkrwjf5.cloudfront.net/42/eum/rum.js";document.body.appendChild(e);if(NREUMQ.a)NREUMQ.a();};NREUMQ.a=window.onload;window.onload=NREUMQ.f;};NREUMQ.push(["nrfj","beacon-1.newrelic.com","5b0327a758","2035125","NFBXZUNRW0ADAkRbCQ0aYENYH0NaBgRfHRAKUEIfQVhF",0,5,new Date().getTime(),"","","","",""]);</script>
55+
</body>
56+
</html>

test/helpers/nock-server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ var reqResMap = {
3333
'/getgzip.php?test=120816_V2_2&file=1_screen.png': 'screenshotFullResolution.png',
3434
'/cancelTest.php?test=120816_V2_2': 'cancel.html',
3535
'/cancelTest.php?test=120816_V2_3': 'cancelNotCancelled.html',
36+
'/video/create.php?tests=130416_YS_KD4-r%3A3-c%3A1%2C130416_W6_KEE-r%3A8-c%3A1&f=json&end=visual': 'createVideo.json',
37+
'/video/view.php?embed=1&id=130416_36ed6e37013655a14b2b857cdccec99db72adcaa': 'embeddedVideoPlayer.html',
3638

3739
// test results for multi runs with/without custom median metric
3840
'/xmlResult.php?test=130619_KK_6A2': 'testResultsMultiRunsDefaultMedianMetric.xml',

test/helpers/response-objects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var fs = require('fs'),
99

1010
var PATH_OBJECTS = path.join(__dirname, '../fixtures/objects');
1111

12-
var reExtensions = /^\.(?:json|txt)$/i,
12+
var reExtensions = /^\.(?:json|txt|html)$/i,
1313
reJSONExt = /^\.json$/i,
1414
reEOFNewLine = /\s+$/;
1515

test/nock-test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,22 @@ describe('Example WebPageTest', function() {
254254
});
255255
});
256256

257+
it('creates a video', function (done) {
258+
wpt.createVideo('130416_YS_KD4-r:3-c:1,130416_W6_KEE-r:8-c:1', {}, function (err, data) {
259+
if (err) throw err;
260+
assert.deepEqual(data, ResponseObjects.createVideo);
261+
done();
262+
});
263+
});
264+
265+
it('get the url of an embedded video', function (done){
266+
wpt.getEmbedVideoPlayer('130416_36ed6e37013655a14b2b857cdccec99db72adcaa', {}, function (err, data) {
267+
if (err) throw err;
268+
assert.equal(data, ResponseObjects.embeddedVideoPlayer + "\n");
269+
done();
270+
});
271+
});
272+
257273
// not found / invalid
258274

259275
it('gets an invalid test status request then returns a not found test status object', function(done) {

0 commit comments

Comments
 (0)