Bug 1383122 - P3. Don't set src attribute to null. r=jwwang

Setting the src attribute to null was incorrect, per spec https://www.w3.org/TR/WebIDL-1/#es-DOMString, if null is passed, this is to be treated as ToString(null), which is "null" (https://tc39.github.io/ecma262/#sec-tostring).
Hence setting src to null will cause a 404 error as it attempts to load "null".

To unload the element, recommended practice is:
Per spec:
https://html.spec.whatwg.org/multipage/media.html#best-practices-for-authors-using-media-elements
"by removing the element's src attribute and any source element descendants, and invoking the element's load() method."

MozReview-Commit-ID: 5Lq13CeDCSZ

--HG--
extra : rebase_source : 806bccb32fa0542ea3be3025a31da97bb331b29c
This commit is contained in:
Jean-Yves Avenard 2017-07-21 19:05:54 +02:00
Родитель 9b0e4b6c44
Коммит 64c70317ce
3 изменённых файлов: 9 добавлений и 10 удалений

Просмотреть файл

@ -22,9 +22,8 @@ function runWithMSE(testFunction) {
document.body.appendChild(el);
SimpleTest.registerCleanupFunction(function () {
el.remove();
// Don't trigger load algorithm to prevent 'error' events.
el.preload = "none";
el.src = null;
el.removeAttribute("src");
el.load();
});
testFunction(ms, el);

Просмотреть файл

@ -380,8 +380,8 @@ function ProcessInitData(v, test, token, initData, sessionType) {
function CleanUpMedia(v) {
v.setMediaKeys(null);
v.remove();
v.onerror = null;
v.src = null;
v.removeAttribute("src");
v.load();
}
/*

Просмотреть файл

@ -122,13 +122,13 @@ function nextTest() {
if (gVideo) {
gVideo.remove();
gVideo.preload = "none"; // Don't trigger load algorithm.
gVideo.src = null;
gVideo.removeAttribute("src");
gVideo.load();
}
gVideo = null;
SpecialPowers.forceGC();
SpecialPowers.forceGC();
gVideo = createVideo();
gVideo.expectedResult = gTests[gTestNum].result;
gVideo.testDescription = gTests[gTestNum].description;
@ -141,7 +141,7 @@ function nextTest() {
gVideo.src = url;
//dump("Starting test " + gTestNum + " at " + gVideo.src + " expecting:" + gVideo.expectedResult + "\n");
if (!gTestedRemoved) {
document.body.appendChild(gVideo);
document.body.appendChild(gVideo);
// Will cause load() to be invoked.
} else {
gVideo.load();