LayoutTests/ChangeLog

 12011-02-08 Anna Cavender <annacc@timberline.kir.corp.google.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Remove special file:// treatment of http/test/media
 6 Requires access to media-file.js and video-test.js inside http/tests/media where local server will run.
 7
 8 Bug 54028 - http/tests/media should be served over HTTP (not from local file)
 9 https://bugs.webkit.org/show_bug.cgi?id=54028
 10
 11 * http/tests/media/media-file.js: Added.
 12 ():
 13 (mimeTypeForExtension):
 14 (setSrcByTagName):
 15 (setSrcById):
 16 (stripExtension):
 17 * http/tests/media/video-test.js: Added.
 18 (disableFullTestDetailsPrinting):
 19 (enableFullTestDetailsPrinting):
 20 (logConsole):
 21 (findMediaElement):
 22 (testAndEnd):
 23 (test):
 24 (testExpected):
 25 (reportExpected):
 26 (runSilently):
 27 (run):
 28 (waitForEventAndEnd):
 29 (waitForEvent._eventCallback):
 30 (waitForEvent):
 31 (waitForEventTestAndEnd):
 32 (waitForEventAndFail):
 33 (waitForEventAndTest._eventCallback):
 34 (waitForEventAndTest):
 35 (testException):
 36 (endTest):
 37 (endTestLater):
 38 (failTestIn):
 39 (failTest):
 40 (logResult):
 41 (consoleWrite):
 42 (relativeURL):
 43 (isInTimeRanges):
 44
1452011-02-08 Xiaomei Ji <xji@chromium.org>
246
347 Unreviewed.

LayoutTests/http/tests/media/media-file.js

 1var audioCodecs = [
 2 ["audio/wav", "wav"],
 3 ["audio/aac", "m4a"],
 4 ["audio/mpeg", "mp3"],
 5 ["audio/ogg", "oga"]
 6];
 7
 8var videoCodecs = [
 9 ["video/mp4", "mp4"],
 10 ["video/mpeg", "mpg"],
 11 ["video/quicktime", "mov"],
 12 ["video/ogg", "ogv"]
 13];
 14
 15function findMediaFile(tagName, name) {
 16 var codecs;
 17 if (tagName == "audio")
 18 codecs = audioCodecs;
 19 else
 20 codecs = videoCodecs;
 21
 22 var element = document.getElementsByTagName(tagName)[0];
 23 if (!element)
 24 element = document.createElement(tagName);
 25
 26 for (var i = 0; i < codecs.length; ++i) {
 27 if (element.canPlayType(codecs[i][0]))
 28 return name + "." + codecs[i][1];
 29 }
 30
 31 return "";
 32}
 33
 34function mimeTypeForExtension(extension) {
 35 for (var i = 0; i < videoCodecs.length; ++i) {
 36 if (extension == videoCodecs[i][1])
 37 return videoCodecs[i][0];
 38 }
 39 for (var i = 0; i < audioCodecs.length; ++i) {
 40 if (extension == audioCodecs[i][1])
 41 return audioCodecs[i][0];
 42 }
 43
 44 return "";
 45}
 46
 47function setSrcByTagName(tagName, src) {
 48 var elements = document.getElementsByTagName(tagName);
 49 if (elements) {
 50 for (var i = 0; i < elements.length; ++i)
 51 elements[i].src = src;
 52 }
 53}
 54
 55function setSrcById(id, src) {
 56 var element = document.getElementById(id);
 57 if (element)
 58 element.src = src;
 59}
 60
 61function stripExtension(filename) {
 62 var lastPeriodIndex = filename.lastIndexOf(".");
 63 if (lastPeriodIndex > 0)
 64 return filename.substring(0, lastPeriodIndex);
 65 return filename;
 66}
 67
 68
 69

LayoutTests/http/tests/media/video-test.js

 1
 2var video = null;
 3var mediaElement = null;
 4var console = null;
 5var printFullTestDetails = true; // This is optionaly switched of by test whose tested values can differ. (see disableFullTestDetailsPrinting())
 6var Failed = false;
 7
 8findMediaElement();
 9logConsole();
 10
 11if (window.layoutTestController) {
 12 layoutTestController.dumpAsText();
 13 layoutTestController.waitUntilDone();
 14}
 15
 16function disableFullTestDetailsPrinting()
 17{
 18 printFullTestDetails = false;
 19}
 20
 21function enableFullTestDetailsPrinting()
 22{
 23 printFullTestDetails = true;
 24}
 25
 26function logConsole()
 27{
 28 if (!console && document.body) {
 29 console = document.createElement('div');
 30 document.body.appendChild(console);
 31 }
 32 return console;
 33}
 34
 35function findMediaElement()
 36{
 37 try {
 38 video = document.getElementsByTagName('video')[0];
 39 if (video)
 40 mediaElement = video;
 41 } catch (ex) { }
 42}
 43
 44function testAndEnd(testFuncString)
 45{
 46 test(testFuncString, true);
 47}
 48
 49function test(testFuncString, endit)
 50{
 51 logResult(eval(testFuncString), "TEST(" + testFuncString + ")");
 52 if (endit)
 53 endTest();
 54}
 55
 56function testExpected(testFuncString, expected, comparison)
 57{
 58 try {
 59 var observed = eval(testFuncString);
 60 } catch (ex) {
 61 consoleWrite(ex);
 62 return;
 63 }
 64
 65 if (comparison === undefined)
 66 comparison = '==';
 67
 68 var success = false;
 69 switch (comparison)
 70 {
 71 case '<': success = observed < expected; break;
 72 case '<=': success = observed <= expected; break;
 73 case '>': success = observed > expected; break;
 74 case '>=': success = observed >= expected; break;
 75 case '!=': success = observed != expected; break;
 76 case '==': success = observed == expected; break;
 77 }
 78
 79 reportExpected(success, testFuncString, comparison, expected, observed)
 80}
 81
 82var testNumber = 0;
 83
 84function reportExpected(success, testFuncString, comparison, expected, observed)
 85{
 86 testNumber++;
 87
 88 var msg = "Test " + testNumber;
 89
 90 if (printFullTestDetails || !success)
 91 msg = "EXPECTED (<em>" + testFuncString + " </em>" + comparison + " '<em>" + expected + "</em>')";
 92
 93 if (!success)
 94 msg += ", OBSERVED '<em>" + observed + "</em>'";
 95
 96 logResult(success, msg);
 97}
 98
 99function runSilently(testFuncString)
 100{
 101 if (printFullTestDetails)
 102 consoleWrite("RUN(" + testFuncString + ")");
 103 try {
 104 eval(testFuncString);
 105 } catch (ex) {
 106 if (!printFullTestDetails) {
 107 // No details were printed previous, give some now.
 108 // This will be helpful in case of error.
 109 logResult(Failed, "Error in RUN(" + testFuncString + "):");
 110 }
 111 logResult(Failed, "<span style='color:red'>"+ex+"</span>");
 112 }
 113}
 114
 115function run(testFuncString)
 116{
 117 consoleWrite("RUN(" + testFuncString + ")");
 118 try {
 119 eval(testFuncString);
 120 } catch (ex) {
 121 consoleWrite(ex);
 122 }
 123}
 124
 125function waitForEventAndEnd(eventName, funcString)
 126{
 127 waitForEvent(eventName, funcString, true)
 128}
 129
 130function waitForEvent(eventName, func, endit)
 131{
 132 function _eventCallback(event)
 133 {
 134 consoleWrite("EVENT(" + eventName + ")");
 135
 136 if (func)
 137 func(event);
 138
 139 if (endit)
 140 endTest();
 141 }
 142
 143 mediaElement.addEventListener(eventName, _eventCallback);
 144}
 145
 146function waitForEventTestAndEnd(eventName, testFuncString)
 147{
 148 waitForEventAndTest(eventName, testFuncString, true);
 149}
 150
 151function waitForEventAndFail(eventName)
 152{
 153 waitForEventAndTest(eventName, "false", true);
 154}
 155
 156function waitForEventAndTest(eventName, testFuncString, endit)
 157{
 158 function _eventCallback(event)
 159 {
 160 logResult(eval(testFuncString), "EVENT(" + eventName + ") TEST(" + testFuncString + ")");
 161 if (endit)
 162 endTest();
 163 }
 164
 165 mediaElement.addEventListener(eventName, _eventCallback);
 166}
 167
 168function testException(testString, exceptionString)
 169{
 170 try {
 171 eval(testString);
 172 } catch (ex) {
 173 logResult(ex.code == eval(exceptionString), "TEST(" + testString + ") THROWS("+exceptionString+")");
 174 }
 175}
 176
 177var testEnded = false;
 178
 179function endTest()
 180{
 181 consoleWrite("END OF TEST");
 182 testEnded = true;
 183 if (window.layoutTestController)
 184 layoutTestController.notifyDone();
 185}
 186
 187function endTestLater()
 188{
 189 setTimeout(endTest, 250);
 190}
 191
 192function failTestIn(ms)
 193{
 194 setTimeout(function () {
 195 consoleWrite("FAIL: did not end fast enough");
 196 endTest();
 197 }, ms);
 198}
 199
 200function failTest(text)
 201{
 202 logResult(Failed, text);
 203 endTest();
 204}
 205
 206
 207function logResult(success, text)
 208{
 209 if (success)
 210 consoleWrite(text + " <span style='color:green'>OK</span>");
 211 else
 212 consoleWrite(text + " <span style='color:red'>FAIL</span>");
 213}
 214
 215function consoleWrite(text)
 216{
 217 if (testEnded)
 218 return;
 219 logConsole().innerHTML += text + "<br>";
 220}
 221
 222function relativeURL(url)
 223{
 224 return url.substr(url.indexOf('/media/')+7);
 225}
 226
 227
 228function isInTimeRanges(ranges, time)
 229{
 230 var i = 0;
 231 for (i = 0; i < ranges.length; ++i) {
 232 if (time >= ranges.start(i) && time <= ranges.end(i)) {
 233 return true;
 234 }
 235 }
 236 return false;
 237}

Tools/ChangeLog

 12011-02-08 Anna Cavender <annacc@timberline.kir.corp.google.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Remove special file:// treatment of http/test/media
 6
 7 Bug 54028 - http/tests/media should be served over HTTP (not from local file)
 8 https://bugs.webkit.org/show_bug.cgi?id=54028
 9
 10 * Scripts/old-run-webkit-tests:
 11 * Scripts/webkitpy/layout_tests/port/base.py:
 12
1132011-02-08 Sam Weinig <sam@webkit.org>
214
315 Reviewed by Anders Carlsson.

Tools/Scripts/old-run-webkit-tests

@@for my $test (@tests) {
766766 print OUT "$errorMessagePath\n";
767767 }
768768 }
769  } elsif ($test !~ /^http\/tests\/local\// && $test !~ /^http\/tests\/ssl\// && $test !~ /^http\/tests\/wml\// && $test !~ /^http\/tests\/media\//) {
 769 } elsif ($test !~ /^http\/tests\/local\// && $test !~ /^http\/tests\/ssl\// && $test !~ /^http\/tests\/wml\//) {
770770 my $path = canonpath($test);
771771 $path =~ s/^http\/tests\///;
772772 print OUT "http://127.0.0.1:$httpdPort/$path$suffixExpectedHash\n";

Tools/Scripts/webkitpy/layout_tests/port/base.py

@@class Port(object):
357357 # logic in run-webkit-tests.
358358 #
359359 # TODO(dpranke): remove the media reference and the SSL reference?
360  if (port and not relative_path.startswith("local/") and
361  not relative_path.startswith("media/")):
 360 if (port and not relative_path.startswith("local/")):
362361 if relative_path.startswith("ssl/"):
363362 port += 443
364363 protocol = "https"