Bug 1302038 part 2 - Add DocumentTimelineOptions dictionary. r=birtles,smaug

MozReview-Commit-ID: 6i0PafTmFFo

--HG--
extra : rebase_source : 7c572ed3a94eda250928019b7403ab6b28eafc0b
This commit is contained in:
Mantaroh Yoshinaga 2016-09-28 16:56:24 +09:00
Родитель a8d0ee0293
Коммит 32ca318289
6 изменённых файлов: 22 добавлений и 28 удалений

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

@ -46,7 +46,7 @@ DocumentTimeline::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
/* static */ already_AddRefed<DocumentTimeline>
DocumentTimeline::Constructor(const GlobalObject& aGlobal,
const DOMHighResTimeStamp& aOriginTime,
const DocumentTimelineOptions& aOptions,
ErrorResult& aRv)
{
nsIDocument* doc = AnimationUtils::GetCurrentRealmDocument(aGlobal.Context());
@ -54,12 +54,11 @@ DocumentTimeline::Constructor(const GlobalObject& aGlobal,
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
TimeDuration originTime =
TimeDuration::FromMilliseconds(aOptions.mOriginTime);
TimeDuration originTime = TimeDuration::FromMilliseconds(aOriginTime);
if (originTime == TimeDuration::Forever() ||
originTime == -TimeDuration::Forever()) {
nsAutoString inputOriginTime;
inputOriginTime.AppendFloat(aOriginTime);
aRv.ThrowTypeError<dom::MSG_TIME_VALUE_OUT_OF_RANGE>(
NS_LITERAL_STRING("Origin time"));
return nullptr;

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

@ -7,6 +7,7 @@
#ifndef mozilla_dom_DocumentTimeline_h
#define mozilla_dom_DocumentTimeline_h
#include "mozilla/dom/DocumentTimelineBinding.h"
#include "mozilla/TimeStamp.h"
#include "AnimationTimeline.h"
#include "nsIDocument.h"
@ -54,7 +55,7 @@ public:
static already_AddRefed<DocumentTimeline>
Constructor(const GlobalObject& aGlobal,
const DOMHighResTimeStamp& aOriginTime,
const DocumentTimelineOptions& aOptions,
ErrorResult& aRv);
// AnimationTimeline methods

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

@ -12,13 +12,17 @@
// inside the allowed range will just mean we overflow elsewhere.
test(function(t) {
assert_throws({name: 'TypeError'},
function() { new DocumentTimeline(Number.MAX_SAFE_INTEGER); });
assert_throws({ name: 'TypeError'},
function() {
new DocumentTimeline({ originTime: Number.MAX_SAFE_INTEGER });
});
}, 'Calculated current time is positive infinity');
test(function(t) {
assert_throws({name: 'TypeError'},
function() { new DocumentTimeline(-1 * Number.MAX_SAFE_INTEGER); });
assert_throws({ name: 'TypeError'},
function() {
new DocumentTimeline({ originTime: -1 * Number.MAX_SAFE_INTEGER });
});
}, 'Calculated current time is negative infinity');
done();

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

@ -10,7 +10,11 @@
* liability, trademark and document use rules apply.
*/
dictionary DocumentTimelineOptions {
DOMHighResTimeStamp originTime = 0;
};
[Func="nsDocument::IsWebAnimationsEnabled",
Constructor (DOMHighResTimeStamp originTime)]
Constructor (optional DocumentTimelineOptions options)]
interface DocumentTimeline : AnimationTimeline {
};

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

@ -1,17 +0,0 @@
[constructor.html]
type: testharness
[An origin time of zero is used when none is supplied]
expected: FAIL
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1302038
[A zero origin time produces a document timeline with a current time identical to the default document timeline]
expected: FAIL
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1302038
[A positive origin time makes the document timeline's current time lag behind the default document timeline]
expected: FAIL
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1302038
[A negative origin time makes the document timeline's current time run ahead of the default document timeline]
expected: FAIL
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1302038

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

@ -12,7 +12,10 @@ interface AnimationTimeline {
};
</script>
<script type="text/plain" id="DocumentTimeline-IDL">
[Constructor (DOMHighResTimeStamp originTime)]
dictionary DocumentTimelineOptions {
DOMHighResTimeStamp originTime = 0;
};
[Constructor (optional DocumentTimelineOptions options)]
interface DocumentTimeline : AnimationTimeline {
};
</script>