зеркало из https://github.com/mozilla/gecko-dev.git
Bug 908390 followup. Fix up event timestamps on workers, and enable the test that was supposed to test for it. r=khuey pending
This commit is contained in:
Родитель
a4ddaa8f72
Коммит
67df248e76
|
@ -997,16 +997,14 @@ Event::TimeStamp() const
|
|||
}
|
||||
|
||||
// For dedicated workers, we should make times relative to the navigation
|
||||
// start of the document that created the worker. We currently don't have
|
||||
// that information handy so for now we treat shared workers and dedicated
|
||||
// workers alike and make times relative to the worker creation time. We can
|
||||
// fix this when we implement WorkerPerformance.
|
||||
// start of the document that created the worker, which is the same as the
|
||||
// timebase for performance.now().
|
||||
workers::WorkerPrivate* workerPrivate =
|
||||
workers::GetCurrentThreadWorkerPrivate();
|
||||
MOZ_ASSERT(workerPrivate);
|
||||
|
||||
TimeDuration duration =
|
||||
mEvent->timeStamp - workerPrivate->CreationTimeStamp();
|
||||
mEvent->timeStamp - workerPrivate->NowBaseTimeStamp();
|
||||
return duration.ToMilliseconds();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,14 +16,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=77992
|
|||
<pre id="test">
|
||||
<script type="text/js-worker" id="worker-src">
|
||||
// Simply returns the event timestamp
|
||||
// (Since we know that this isn't implemented correctly for dedicated workers
|
||||
// and isn't likely to be implemented correctly until we implement
|
||||
// WorkerPerformance, we make this return the *wrong* result so long as
|
||||
// 'performance' is not available. Then we can use this in a todo() test
|
||||
// below and when we come to implement WorkerPerformance the todo() check
|
||||
// should fail reminding us to update this test.)
|
||||
onmessage = function(evt) {
|
||||
postMessage(typeof performance === "object" ? evt.timeStamp : 0);
|
||||
postMessage(evt.timeStamp);
|
||||
}
|
||||
</script>
|
||||
<script type="text/js-worker" id="shared-worker-src">
|
||||
|
@ -79,11 +73,11 @@ function testWorkerEvents() {
|
|||
var worker = new Worker(window.URL.createObjectURL(blob));
|
||||
worker.onmessage = function(evt) {
|
||||
var timeAfterEvent = window.performance.now();
|
||||
todo(evt.data > timeBeforeEvent &&
|
||||
evt.data < timeAfterEvent,
|
||||
"Event timestamp in dedicated worker (" + evt.data +
|
||||
") is in expected range: (" +
|
||||
timeBeforeEvent + ", " + timeAfterEvent + ")");
|
||||
ok(evt.data > timeBeforeEvent &&
|
||||
evt.data < timeAfterEvent,
|
||||
"Event timestamp in dedicated worker (" + evt.data +
|
||||
") is in expected range: (" +
|
||||
timeBeforeEvent + ", " + timeAfterEvent + ")");
|
||||
worker.terminate();
|
||||
testSharedWorkerEvents();
|
||||
};
|
||||
|
|
|
@ -2137,9 +2137,9 @@ WorkerPrivateParent<Derived>::WorkerPrivateParent(
|
|||
|
||||
RuntimeService::GetDefaultJSSettings(mJSSettings);
|
||||
|
||||
if (IsDedicatedWorker() && aLoadInfo.mWindow &&
|
||||
aLoadInfo.mWindow->GetPerformance()) {
|
||||
mNowBaseTimeStamp = aLoadInfo.mWindow->GetPerformance()->GetDOMTiming()->
|
||||
if (IsDedicatedWorker() && mLoadInfo.mWindow &&
|
||||
mLoadInfo.mWindow->GetPerformance()) {
|
||||
mNowBaseTimeStamp = mLoadInfo.mWindow->GetPerformance()->GetDOMTiming()->
|
||||
GetNavigationStartTimeStamp();
|
||||
} else {
|
||||
mNowBaseTimeStamp = CreationTimeStamp();
|
||||
|
|
Загрузка…
Ссылка в новой задаче