mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 677122 - Update start/end times of mediafragment URL on hashchanges r=bz
--HG-- extra : rebase_source : 91fa2211dbc4c9c839f22fcb086e0b3a1a0cfef6
This commit is contained in:
parent
96258a9e18
commit
cffc8d1968
@ -63,6 +63,7 @@ protected:
|
||||
|
||||
// Sets document <title> to reflect the file name and description.
|
||||
void UpdateTitle(nsIChannel* aChannel);
|
||||
void InsertMediaFragmentScript();
|
||||
|
||||
nsresult CreateSyntheticVideoDocument(nsIChannel* aChannel,
|
||||
nsIStreamListener** aListener);
|
||||
@ -106,6 +107,29 @@ VideoDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject)
|
||||
LinkStylesheet(NS_LITERAL_STRING("resource://gre/res/TopLevelVideoDocument.css"));
|
||||
LinkStylesheet(NS_LITERAL_STRING("chrome://global/skin/TopLevelVideoDocument.css"));
|
||||
}
|
||||
|
||||
if (aScriptGlobalObject) {
|
||||
InsertMediaFragmentScript();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VideoDocument::InsertMediaFragmentScript()
|
||||
{
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::script, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
if (!nodeInfo)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
nsRefPtr<nsGenericHTMLElement> script = NS_NewHTMLScriptElement(nodeInfo.forget());
|
||||
script->SetTextContent(NS_LITERAL_STRING("window.addEventListener('hashchange',function(e){document.querySelector('audio,video').src=e.newURL;},false);"));
|
||||
|
||||
Element* head = GetHeadElement();
|
||||
head->AppendChildTo(script, false);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -108,6 +108,7 @@ _TEST_FILES = test_bug1682.html \
|
||||
test_bug677495-1.html \
|
||||
test_bug742261.html \
|
||||
test_bug741266.html \
|
||||
test_bug677122.html \
|
||||
$(NULL)
|
||||
|
||||
ifneq (mobile,$(MOZ_BUILD_APP))
|
||||
|
95
content/html/document/test/test_bug677122.html
Normal file
95
content/html/document/test/test_bug677122.html
Normal file
@ -0,0 +1,95 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: MediaDocument hashchange mediafragment.</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var iframe;
|
||||
var url = "../../../media/test/seek.ogv";
|
||||
var expects = 5;
|
||||
var count = 0;
|
||||
var test;
|
||||
var tests = [
|
||||
{ start: 1, end: 2 },
|
||||
{ start: 3, end: 4 }
|
||||
];
|
||||
|
||||
var next = function () {
|
||||
|
||||
test = tests.shift();
|
||||
if (test) {
|
||||
|
||||
iframe.src = url + "#t=" + test.start + "," + test.end;
|
||||
} else {
|
||||
|
||||
ok(expects === ++count, "Expected number of tests run. Expected: " + expects + " Actual: " + count);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
};
|
||||
|
||||
var load = function (e) {
|
||||
|
||||
iframe = document.getElementById("iframe");
|
||||
var media = iframe.contentWindow.document.querySelector("audio,video");
|
||||
|
||||
media.addEventListener("seeked", function () {
|
||||
|
||||
var currentTime = Math.round(media.currentTime);
|
||||
|
||||
count++;
|
||||
ok(currentTime >= test.start, "Hashchange mediafragment start. Expected: " + test.start + " Actual: " + currentTime);
|
||||
}, false);
|
||||
|
||||
// This is testing the first test.
|
||||
// The fist test's end happens to be in the middle of the video,
|
||||
// so a pause is fired.
|
||||
media.addEventListener("pause", function () {
|
||||
|
||||
var currentTime = Math.round(media.currentTime);
|
||||
|
||||
if (count === 1) {
|
||||
|
||||
count++;
|
||||
ok(currentTime === test.end, "Hashchange mediafragment end. Expected: " + test.end + " Actual: " + currentTime);
|
||||
}
|
||||
|
||||
// Give whatever the media code is doing right now a chance to complete
|
||||
// before we seek.
|
||||
SimpleTest.executeSoon(next);
|
||||
}, false);
|
||||
|
||||
// Having an ended event ensures we're more likely to fail, instead of timing out.
|
||||
// This is testing the end in the second test.
|
||||
// The second test's end happens at the end of the video,
|
||||
// so a end is fired.
|
||||
media.addEventListener("ended", function () {
|
||||
|
||||
var currentTime = Math.round(media.currentTime);
|
||||
|
||||
if (count === 3) {
|
||||
|
||||
count++;
|
||||
ok(currentTime === test.end, "Hashchange mediafragment end. Expected: " + test.end + " Actual: " + currentTime);
|
||||
}
|
||||
|
||||
// Give whatever the media code is doing right now a chance to complete
|
||||
// before we seek.
|
||||
SimpleTest.executeSoon(next);
|
||||
}, false);
|
||||
|
||||
// Give whatever the media code is doing right now a chance to complete
|
||||
// before we seek.
|
||||
SimpleTest.executeSoon(next);
|
||||
};
|
||||
</script>
|
||||
</pre>
|
||||
<iframe id="iframe" src="../../../media/test/seek.ogv" onload="load()"></iframe>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user