Backed out 4 changesets (bug 782751, bug 1127948) for Gaia UI test failures.

Backed out changeset 4d8735e0cc30 (bug 1127948)
Backed out changeset de498dd4e303 (bug 782751)
Backed out changeset fe9436f5474c (bug 782751)
Backed out changeset fff8f6c32743 (bug 782751)
This commit is contained in:
Ryan VanderMeulen 2015-01-30 14:16:40 -05:00
parent eff2f91585
commit 4aa269687d
31 changed files with 147 additions and 785 deletions

View File

@ -19,12 +19,8 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PerformanceEntry)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
PerformanceEntry::PerformanceEntry(nsPerformance* aPerformance,
const nsAString& aName,
const nsAString& aEntryType)
: mPerformance(aPerformance),
mName(aName),
mEntryType(aEntryType)
PerformanceEntry::PerformanceEntry(nsPerformance* aPerformance)
: mPerformance(aPerformance)
{
MOZ_ASSERT(aPerformance, "Parent performance object should be provided");
}

View File

@ -20,9 +20,7 @@ protected:
virtual ~PerformanceEntry();
public:
PerformanceEntry(nsPerformance* aPerformance,
const nsAString& aName,
const nsAString& aEntryType);
explicit PerformanceEntry(nsPerformance* aPerformance);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PerformanceEntry)

View File

@ -1,27 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "PerformanceMark.h"
#include "mozilla/dom/PerformanceMarkBinding.h"
using namespace mozilla::dom;
PerformanceMark::PerformanceMark(nsPerformance* aPerformance,
const nsAString& aName)
: PerformanceEntry(aPerformance, aName, NS_LITERAL_STRING("mark"))
{
MOZ_ASSERT(aPerformance, "Parent performance object should be provided");
mStartTime = aPerformance->GetDOMTiming()->TimeStampToDOMHighRes(mozilla::TimeStamp::Now());
}
PerformanceMark::~PerformanceMark()
{
}
JSObject*
PerformanceMark::WrapObject(JSContext* aCx)
{
return PerformanceMarkBinding::Wrap(aCx, this);
}

View File

@ -1,36 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_performancemark_h___
#define mozilla_dom_performancemark_h___
#include "mozilla/dom/PerformanceEntry.h"
namespace mozilla {
namespace dom {
// http://www.w3.org/TR/user-timing/#performancemark
class PerformanceMark MOZ_FINAL : public PerformanceEntry
{
public:
PerformanceMark(nsPerformance* aPerformance,
const nsAString& aName);
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
virtual DOMHighResTimeStamp StartTime() const MOZ_OVERRIDE
{
return mStartTime;
}
protected:
virtual ~PerformanceMark();
DOMHighResTimeStamp mStartTime;
};
} // namespace dom
} // namespace mozilla
#endif /* mozilla_dom_performancemark_h___ */

View File

@ -1,30 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "PerformanceMeasure.h"
#include "mozilla/dom/PerformanceMeasureBinding.h"
using namespace mozilla::dom;
PerformanceMeasure::PerformanceMeasure(nsPerformance* aPerformance,
const nsAString& aName,
DOMHighResTimeStamp aStartTime,
DOMHighResTimeStamp aEndTime)
: PerformanceEntry(aPerformance, aName, NS_LITERAL_STRING("measure")),
mStartTime(aStartTime),
mDuration(aEndTime - aStartTime)
{
MOZ_ASSERT(aPerformance, "Parent performance object should be provided");
}
PerformanceMeasure::~PerformanceMeasure()
{
}
JSObject*
PerformanceMeasure::WrapObject(JSContext* aCx)
{
return PerformanceMeasureBinding::Wrap(aCx, this);
}

View File

@ -1,44 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_performancemeasure_h___
#define mozilla_dom_performancemeasure_h___
#include "mozilla/dom/PerformanceEntry.h"
namespace mozilla {
namespace dom {
// http://www.w3.org/TR/user-timing/#performancemeasure
class PerformanceMeasure MOZ_FINAL : public PerformanceEntry
{
public:
PerformanceMeasure(nsPerformance* aPerformance,
const nsAString& aName,
DOMHighResTimeStamp aStartTime,
DOMHighResTimeStamp aEndTime);
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
virtual DOMHighResTimeStamp StartTime() const MOZ_OVERRIDE
{
return mStartTime;
}
virtual DOMHighResTimeStamp Duration() const MOZ_OVERRIDE
{
return mDuration;
}
protected:
virtual ~PerformanceMeasure();
DOMHighResTimeStamp mStartTime;
DOMHighResTimeStamp mDuration;
};
} // namespace dom
} // namespace mozilla
#endif /* mozilla_dom_performancemeasure_h___ */

View File

@ -23,9 +23,8 @@ NS_IMPL_ADDREF_INHERITED(PerformanceResourceTiming, PerformanceEntry)
NS_IMPL_RELEASE_INHERITED(PerformanceResourceTiming, PerformanceEntry)
PerformanceResourceTiming::PerformanceResourceTiming(nsPerformanceTiming* aPerformanceTiming,
nsPerformance* aPerformance,
const nsAString& aName)
: PerformanceEntry(aPerformance, aName, NS_LITERAL_STRING("resource")),
nsPerformance* aPerformance)
: PerformanceEntry(aPerformance),
mTiming(aPerformanceTiming)
{
MOZ_ASSERT(aPerformance, "Parent performance object should be provided");

View File

@ -28,8 +28,7 @@ public:
PerformanceEntry)
PerformanceResourceTiming(nsPerformanceTiming* aPerformanceTiming,
nsPerformance* aPerformance,
const nsAString& aName);
nsPerformance* aPerformance);
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;

View File

@ -181,8 +181,6 @@ EXPORTS.mozilla.dom += [
'NodeInfoInlines.h',
'NodeIterator.h',
'PerformanceEntry.h',
'PerformanceMark.h',
'PerformanceMeasure.h',
'PerformanceResourceTiming.h',
'ResponsiveImageSelector.h',
'ScreenOrientation.h',
@ -317,8 +315,6 @@ UNIFIED_SOURCES += [
'nsXMLHttpRequest.cpp',
'nsXMLNameSpaceMap.cpp',
'PerformanceEntry.cpp',
'PerformanceMark.cpp',
'PerformanceMeasure.cpp',
'PerformanceResourceTiming.cpp',
'ResponsiveImageSelector.cpp',
'ScriptSettings.cpp',

View File

@ -14,7 +14,6 @@
#include "mozilla/dom/Attr.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/NamedNodeMapBinding.h"
#include "mozilla/dom/NodeInfoInlines.h"
#include "nsAttrName.h"
#include "nsContentUtils.h"
#include "nsError.h"

View File

@ -11,21 +11,17 @@
#include "nsContentUtils.h"
#include "nsIScriptSecurityManager.h"
#include "nsIDOMWindow.h"
#include "nsILoadInfo.h"
#include "nsIURI.h"
#include "nsThreadUtils.h"
#include "PerformanceEntry.h"
#include "PerformanceMark.h"
#include "PerformanceMeasure.h"
#include "PerformanceResourceTiming.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/PerformanceBinding.h"
#include "mozilla/dom/PerformanceTimingBinding.h"
#include "mozilla/dom/PerformanceNavigationBinding.h"
#include "mozilla/TimeStamp.h"
#include "nsThreadUtils.h"
#include "nsILoadInfo.h"
using namespace mozilla;
using namespace mozilla::dom;
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsPerformanceTiming, mPerformance)
@ -329,7 +325,7 @@ nsPerformanceTiming::ResponseStart()
DOMHighResTimeStamp
nsPerformanceTiming::ResponseEndHighRes()
{
if (!IsInitialized()) {
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized()) {
return mZeroTime;
}
if (mResponseEnd.IsNull() ||
@ -354,7 +350,7 @@ nsPerformanceTiming::IsInitialized() const
JSObject*
nsPerformanceTiming::WrapObject(JSContext *cx)
{
return PerformanceTimingBinding::Wrap(cx, this);
return dom::PerformanceTimingBinding::Wrap(cx, this);
}
@ -376,7 +372,7 @@ nsPerformanceNavigation::~nsPerformanceNavigation()
JSObject*
nsPerformanceNavigation::WrapObject(JSContext *cx)
{
return PerformanceNavigationBinding::Wrap(cx, this);
return dom::PerformanceNavigationBinding::Wrap(cx, this);
}
@ -453,13 +449,13 @@ nsPerformance::Navigation()
DOMHighResTimeStamp
nsPerformance::Now()
{
return GetDOMTiming()->TimeStampToDOMHighRes(TimeStamp::Now());
return GetDOMTiming()->TimeStampToDOMHighRes(mozilla::TimeStamp::Now());
}
JSObject*
nsPerformance::WrapObject(JSContext *cx)
{
return PerformanceBinding::Wrap(cx, this);
return dom::PerformanceBinding::Wrap(cx, this);
}
void
@ -487,7 +483,7 @@ nsPerformance::GetEntriesByType(const nsAString& entryType,
void
nsPerformance::GetEntriesByName(const nsAString& name,
const Optional<nsAString>& entryType,
const mozilla::dom::Optional<nsAString>& entryType,
nsTArray<nsRefPtr<PerformanceEntry> >& retval)
{
MOZ_ASSERT(NS_IsMainThread());
@ -503,28 +499,11 @@ nsPerformance::GetEntriesByName(const nsAString& name,
}
}
void
nsPerformance::ClearEntries(const Optional<nsAString>& aEntryName,
const nsAString& aEntryType)
{
for (uint32_t i = 0; i < mEntries.Length();) {
if ((!aEntryName.WasPassed() ||
mEntries[i]->GetName().Equals(aEntryName.Value())) &&
(aEntryType.IsEmpty() ||
mEntries[i]->GetEntryType().Equals(aEntryType))) {
mEntries.RemoveElementAt(i);
} else {
++i;
}
}
}
void
nsPerformance::ClearResourceTimings()
{
MOZ_ASSERT(NS_IsMainThread());
ClearEntries(Optional<nsAString>(),
NS_LITERAL_STRING("resource"));
mEntries.Clear();
}
void
@ -550,7 +529,6 @@ nsPerformance::AddEntry(nsIHttpChannel* channel,
// Don't add the entry if the buffer is full
if (mEntries.Length() >= mPrimaryBufferSize) {
NS_WARNING("Performance Entry buffer size maximum reached!");
return;
}
@ -580,16 +558,24 @@ nsPerformance::AddEntry(nsIHttpChannel* channel,
// The PerformanceResourceTiming object will use the nsPerformanceTiming
// object to get all the required timings.
nsRefPtr<PerformanceResourceTiming> performanceEntry =
new PerformanceResourceTiming(performanceTiming, this, entryName);
nsRefPtr<dom::PerformanceResourceTiming> performanceEntry =
new dom::PerformanceResourceTiming(performanceTiming, this);
performanceEntry->SetName(entryName);
performanceEntry->SetEntryType(NS_LITERAL_STRING("resource"));
// If the initiator type had no valid value, then set it to the default
// ("other") value.
if (initiatorType.IsEmpty()) {
initiatorType = NS_LITERAL_STRING("other");
}
performanceEntry->SetInitiatorType(initiatorType);
InsertPerformanceEntry(performanceEntry);
mEntries.InsertElementSorted(performanceEntry,
PerformanceEntryComparator());
if (mEntries.Length() >= mPrimaryBufferSize) {
// call onresourcetimingbufferfull
DispatchBufferFullEvent();
}
}
}
@ -612,226 +598,3 @@ nsPerformance::PerformanceEntryComparator::LessThan(
"Trying to compare null performance entries");
return aElem1->StartTime() < aElem2->StartTime();
}
void
nsPerformance::InsertPerformanceEntry(PerformanceEntry* aEntry)
{
MOZ_ASSERT(aEntry);
MOZ_ASSERT(mEntries.Length() < mPrimaryBufferSize);
if (mEntries.Length() == mPrimaryBufferSize) {
NS_WARNING("Performance Entry buffer size maximum reached!");
return;
}
mEntries.InsertElementSorted(aEntry,
PerformanceEntryComparator());
if (mEntries.Length() == mPrimaryBufferSize) {
// call onresourcetimingbufferfull
DispatchBufferFullEvent();
}
}
void
nsPerformance::Mark(const nsAString& aName, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
// Don't add the entry if the buffer is full
if (mEntries.Length() >= mPrimaryBufferSize) {
NS_WARNING("Performance Entry buffer size maximum reached!");
return;
}
if (IsPerformanceTimingAttribute(aName)) {
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
return;
}
nsRefPtr<PerformanceMark> performanceMark =
new PerformanceMark(this, aName);
InsertPerformanceEntry(performanceMark);
}
void
nsPerformance::ClearMarks(const Optional<nsAString>& aName)
{
MOZ_ASSERT(NS_IsMainThread());
ClearEntries(aName, NS_LITERAL_STRING("mark"));
}
DOMHighResTimeStamp
nsPerformance::ResolveTimestampFromName(const nsAString& aName,
ErrorResult& aRv)
{
nsAutoTArray<nsRefPtr<PerformanceEntry>, 1> arr;
DOMHighResTimeStamp ts;
Optional<nsAString> typeParam;
nsAutoString str;
str.AssignLiteral("mark");
typeParam = &str;
GetEntriesByName(aName, typeParam, arr);
if (!arr.IsEmpty()) {
return arr.LastElement()->StartTime();
}
if (!IsPerformanceTimingAttribute(aName)) {
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
return 0;
}
ts = GetPerformanceTimingFromString(aName);
if (!ts) {
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
return 0;
}
return ConvertDOMMilliSecToHighRes(ts);
}
void
nsPerformance::Measure(const nsAString& aName,
const Optional<nsAString>& aStartMark,
const Optional<nsAString>& aEndMark,
ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
// Don't add the entry if the buffer is full
if (mEntries.Length() >= mPrimaryBufferSize) {
NS_WARNING("Performance Entry buffer size maximum reached!");
return;
}
DOMHighResTimeStamp startTime;
DOMHighResTimeStamp endTime;
if (IsPerformanceTimingAttribute(aName)) {
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
return;
}
if (aStartMark.WasPassed()) {
startTime = ResolveTimestampFromName(aStartMark.Value(), aRv);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
} else {
// Navigation start is used in this case, but since DOMHighResTimeStamp is
// in relation to navigation start, this will be zero if a name is not
// passed.
startTime = 0;
}
if (aEndMark.WasPassed()) {
endTime = ResolveTimestampFromName(aEndMark.Value(), aRv);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
} else {
endTime = Now();
}
nsRefPtr<PerformanceMeasure> performanceMeasure =
new PerformanceMeasure(this, aName, startTime, endTime);
InsertPerformanceEntry(performanceMeasure);
}
void
nsPerformance::ClearMeasures(const Optional<nsAString>& aName)
{
MOZ_ASSERT(NS_IsMainThread());
ClearEntries(aName, NS_LITERAL_STRING("measure"));
}
DOMHighResTimeStamp
nsPerformance::ConvertDOMMilliSecToHighRes(DOMTimeMilliSec aTime) {
// If the time we're trying to convert is equal to zero, it hasn't been set
// yet so just return 0.
if (aTime == 0) {
return 0;
}
return aTime - GetDOMTiming()->GetNavigationStart();
}
// To be removed once bug 1124165 lands
bool
nsPerformance::IsPerformanceTimingAttribute(const nsAString& aName)
{
// Note that toJSON is added to this list due to bug 1047848
static const char* attributes[] =
{"navigationStart", "unloadEventStart", "unloadEventEnd", "redirectStart",
"redirectEnd", "fetchStart", "domainLookupStart", "domainLookupEnd",
"connectStart", "connectEnd", "requestStart", "responseStart",
"responseEnd", "domLoading", "domInteractive", "domContentLoadedEventStart",
"domContentLoadedEventEnd", "domComplete", "loadEventStart",
"loadEventEnd", nullptr};
for (uint32_t i = 0; attributes[i]; ++i) {
if (aName.EqualsASCII(attributes[i])) {
return true;
}
}
return false;
}
DOMTimeMilliSec
nsPerformance::GetPerformanceTimingFromString(const nsAString& aProperty)
{
if (!IsPerformanceTimingAttribute(aProperty)) {
return 0;
}
if (aProperty.EqualsLiteral("navigationStart")) {
// DOMHighResTimeStamp is in relation to navigationStart, so this will be
// zero.
return GetDOMTiming()->GetNavigationStart();
}
if (aProperty.EqualsLiteral("unloadEventStart")) {
return GetDOMTiming()->GetUnloadEventStart();
}
if (aProperty.EqualsLiteral("unloadEventEnd")) {
return GetDOMTiming()->GetUnloadEventEnd();
}
if (aProperty.EqualsLiteral("redirectStart")) {
return Timing()->RedirectStart();
}
if (aProperty.EqualsLiteral("redirectEnd")) {
return Timing()->RedirectEnd();
}
if (aProperty.EqualsLiteral("fetchStart")) {
return Timing()->FetchStart();
}
if (aProperty.EqualsLiteral("domainLookupStart")) {
return Timing()->DomainLookupStart();
}
if (aProperty.EqualsLiteral("domainLookupEnd")) {
return Timing()->DomainLookupEnd();
}
if (aProperty.EqualsLiteral("connectStart")) {
return Timing()->ConnectStart();
}
if (aProperty.EqualsLiteral("connectEnd")) {
return Timing()->ConnectEnd();
}
if (aProperty.EqualsLiteral("requestStart")) {
return Timing()->RequestStart();
}
if (aProperty.EqualsLiteral("responseStart")) {
return Timing()->ResponseStart();
}
if (aProperty.EqualsLiteral("responseEnd")) {
return Timing()->ResponseEnd();
}
if (aProperty.EqualsLiteral("domLoading")) {
return GetDOMTiming()->GetDomLoading();
}
if (aProperty.EqualsLiteral("domInteractive")) {
return GetDOMTiming()->GetDomInteractive();
}
if (aProperty.EqualsLiteral("domContentLoadedEventStart")) {
return GetDOMTiming()->GetDomContentLoadedEventStart();
}
if (aProperty.EqualsLiteral("domContentLoadedEventEnd")) {
return GetDOMTiming()->GetDomContentLoadedEventEnd();
}
if (aProperty.EqualsLiteral("domComplete")) {
return GetDOMTiming()->GetDomComplete();
}
if (aProperty.EqualsLiteral("loadEventStart")) {
return GetDOMTiming()->GetLoadEventStart();
}
if (aProperty.EqualsLiteral("loadEventEnd")) {
return GetDOMTiming()->GetLoadEventEnd();
}
MOZ_CRASH("IsPerformanceTimingAttribute and GetPerformanceTimingFromString are out of sync");
return 0;
}

View File

@ -21,7 +21,6 @@ class nsPerformance;
class nsIHttpChannel;
namespace mozilla {
class ErrorResult;
namespace dom {
class PerformanceEntry;
}
@ -336,26 +335,12 @@ public:
nsITimedChannel* timedChannel);
void ClearResourceTimings();
void SetResourceTimingBufferSize(uint64_t maxSize);
void Mark(const nsAString& aName, mozilla::ErrorResult& aRv);
void ClearMarks(const mozilla::dom::Optional<nsAString>& aName);
void Measure(const nsAString& aName,
const mozilla::dom::Optional<nsAString>& aStartMark,
const mozilla::dom::Optional<nsAString>& aEndMark,
mozilla::ErrorResult& aRv);
void ClearMeasures(const mozilla::dom::Optional<nsAString>& aName);
IMPL_EVENT_HANDLER(resourcetimingbufferfull)
private:
~nsPerformance();
bool IsPerformanceTimingAttribute(const nsAString& aName);
DOMHighResTimeStamp ResolveTimestampFromName(const nsAString& aName, mozilla::ErrorResult& aRv);
DOMTimeMilliSec GetPerformanceTimingFromString(const nsAString& aTimingName);
DOMHighResTimeStamp ConvertDOMMilliSecToHighRes(const DOMTimeMilliSec aTime);
void DispatchBufferFullEvent();
void InsertPerformanceEntry(PerformanceEntry* aEntry);
void ClearEntries(const mozilla::dom::Optional<nsAString>& aEntryName,
const nsAString& aEntryType);
nsCOMPtr<nsPIDOMWindow> mWindow;
nsRefPtr<nsDOMNavigationTiming> mDOMTiming;
nsCOMPtr<nsITimedChannel> mChannel;

View File

@ -770,5 +770,3 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android'
skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s
[test_window_define_nonconfigurable.html]
skip-if = true # bug 1107443 - code for newly-added test was disabled
[test_performance_user_timing.html]

View File

@ -1,306 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=782751
-->
<head>
<title>Test for Bug 782751</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=782751">Mozilla Bug 782751 - User Timing API</a>
<div id="content">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
var index = 0;
var steps = [
// Test single mark addition
function () {
ok(true, "Running mark addition test");
performance.mark("test");
var marks = performance.getEntriesByType("mark");
is(marks.length, 1, "Number of marks should be 1");
var mark = marks[0];
is(mark.name, "test", "mark name should be 'test'");
is(mark.entryType, "mark", "mark type should be 'mark'");
isnot(mark.startTime, 0, "mark start time should not be 0");
is(mark.duration, 0, "mark duration should be 0");
},
// Test multiple mark addition
function () {
ok(true, "Running multiple mark with same name addition test");
performance.mark("test");
performance.mark("test");
performance.mark("test");
var marks_type = performance.getEntriesByType("mark");
is(marks_type.length, 3, "Number of marks by type should be 3");
var marks_name = performance.getEntriesByType("mark");
is(marks_name.length, 3, "Number of marks by name should be 3");
var mark = marks_name[0];
is(mark.name, "test", "mark name should be 'test'");
is(mark.entryType, "mark", "mark type should be 'mark'");
isnot(mark.startTime, 0, "mark start time should not be 0");
is(mark.duration, 0, "mark duration should be 0");
var times = [];
// This also tests the chronological ordering specified as
// required for getEntries in the performance timeline spec.
marks_name.forEach(function(s) {
times.forEach(function(time) {
ok(s.startTime >= time.startTime,
"Times should be equal or increasing between similarly named marks: " + s.startTime + " >= " + time.startTime);
});
times.push(s);
});
},
// Test all marks removal
function () {
ok(true, "Running all mark removal test");
performance.mark("test");
performance.mark("test2");
var marks = performance.getEntriesByType("mark");
is(marks.length, 2, "number of marks before all removal");
performance.clearMarks();
marks = performance.getEntriesByType("mark");
is(marks.length, 0, "number of marks after all removal");
},
// Test single mark removal
function () {
ok(true, "Running removal test (0 'test' marks with other marks)");
performance.mark("test2");
var marks = performance.getEntriesByType("mark");
is(marks.length, 1, "number of marks before all removal");
performance.clearMarks("test");
marks = performance.getEntriesByType("mark");
is(marks.length, 1, "number of marks after all removal");
},
// Test single mark removal
function () {
ok(true, "Running removal test (0 'test' marks with no other marks)");
var marks = performance.getEntriesByType("mark");
is(marks.length, 0, "number of marks before all removal");
performance.clearMarks("test");
marks = performance.getEntriesByType("mark");
is(marks.length, 0, "number of marks after all removal");
},
function () {
ok(true, "Running removal test (1 'test' mark with other marks)");
performance.mark("test");
performance.mark("test2");
var marks = performance.getEntriesByType("mark");
is(marks.length, 2, "number of marks before all removal");
performance.clearMarks("test");
marks = performance.getEntriesByType("mark");
is(marks.length, 1, "number of marks after all removal");
},
function () {
ok(true, "Running removal test (1 'test' mark with no other marks)");
performance.mark("test");
var marks = performance.getEntriesByType("mark");
is(marks.length, 1, "number of marks before all removal");
performance.clearMarks("test");
marks = performance.getEntriesByType("mark");
is(marks.length, 0, "number of marks after all removal");
},
function () {
ok(true, "Running removal test (2 'test' marks with other marks)");
performance.mark("test");
performance.mark("test");
performance.mark("test2");
var marks = performance.getEntriesByType("mark");
is(marks.length, 3, "number of marks before all removal");
performance.clearMarks("test");
marks = performance.getEntriesByType("mark");
is(marks.length, 1, "number of marks after all removal");
},
function () {
ok(true, "Running removal test (2 'test' marks with no other marks)");
performance.mark("test");
performance.mark("test");
var marks = performance.getEntriesByType("mark");
is(marks.length, 2, "number of marks before all removal");
performance.clearMarks("test");
marks = performance.getEntriesByType("mark");
is(marks.length, 0, "number of marks after all removal");
},
// Test mark name being same as navigation timing parameter
function () {
ok(true, "Running mark name collision test");
for (n in performance.timing) {
try {
if (n == "toJSON") {
ok(true, "Skipping toJSON entry in collision test");
continue;
}
performance.mark(n);
ok(false, "Mark name collision test failed for name " + n + ", shouldn't make it here!");
} catch (e) {
ok(e instanceof DOMException, "DOM exception thrown for mark named " + n);
is(e.code, e.SYNTAX_ERR, "DOM exception for name collision is syntax error");
}
};
},
// Test measure
function () {
ok(true, "Running measure addition with no start/end time test");
performance.measure("test");
var measures = performance.getEntriesByType("measure");
is(measures.length, 1, "number of measures should be 1");
var measure = measures[0];
is(measure.name, "test", "measure name should be 'test'");
is(measure.entryType, "measure", "measure type should be 'measure'");
is(measure.startTime, 0, "measure start time should be zero");
ok(measure.duration >= 0, "measure duration should not be negative");
},
function () {
ok(true, "Running measure addition with only start time test");
performance.mark("test1");
performance.measure("test", "test1", undefined);
var measures = performance.getEntriesByName("test", "measure");
var marks = performance.getEntriesByName("test1", "mark");
var measure = measures[0];
var mark = marks[0];
is(measure.startTime, mark.startTime, "measure start time should be equal to the mark startTime");
ok(measure.duration >= 0, "measure duration should not be negative");
},
function () {
ok(true, "Running measure addition with only end time test");
performance.mark("test1");
performance.measure("test", undefined, "test1");
var measures = performance.getEntriesByName("test", "measure");
var marks = performance.getEntriesByName("test1", "mark");
var measure = measures[0];
var mark = marks[0];
ok(measure.duration >= 0, "measure duration should not be negative");
},
// Test measure picking latest version of similarly named tags
function () {
ok(true, "Running multiple mark with same name addition test");
performance.mark("test");
performance.mark("test");
performance.mark("test");
performance.mark("test2");
var marks_name = performance.getEntriesByName("test");
is(marks_name.length, 3, "Number of marks by name should be 3");
var marks_name2 = performance.getEntriesByName("test2");
is(marks_name2.length, 1, "Number of marks by name should be 1");
var test_mark = marks_name2[0];
performance.measure("test", "test", "test2");
var measures_type = performance.getEntriesByType("measure");
var last_mark = marks_name[marks_name.length - 1];
is(measures_type.length, 1, "Number of measures by type should be 1");
var measure = measures_type[0];
is(measure.startTime, last_mark.startTime, "Measure start time should be the start time of the latest 'test' mark");
// Tolerance testing to avoid oranges, since we're doing double math across two different languages.
ok(measure.duration - (test_mark.startTime - last_mark.startTime) < .00001,
"Measure duration ( " + measure.duration + ") should be difference between two marks");
},
// Test all measure removal
function () {
ok(true, "Running all measure removal test");
performance.measure("test");
performance.measure("test2");
var measures = performance.getEntriesByType("measure");
is(measures.length, 2, "measure entries should be length 2");
performance.clearMeasures();
measures = performance.getEntriesByType("measure");
is(measures.length, 0, "measure entries should be length 0");
},
// Test single measure removal
function () {
ok(true, "Running all measure removal test");
performance.measure("test");
performance.measure("test2");
var measures = performance.getEntriesByType("measure");
is(measures.length, 2, "measure entries should be length 2");
performance.clearMeasures("test");
measures = performance.getEntriesByType("measure");
is(measures.length, 1, "measure entries should be length 1");
},
// Test measure with invalid start time mark name
function () {
ok(true, "Running measure invalid start test");
try {
performance.measure("test", "notamark");
ok(false, "invalid measure start time exception not thrown!");
} catch (e) {
ok(e instanceof DOMException, "DOM exception thrown for invalid measure");
is(e.code, e.SYNTAX_ERR, "DOM exception for invalid time is syntax error");
}
},
// Test measure with invalid end time mark name
function () {
ok(true, "Running measure invalid end test");
try {
performance.measure("test", undefined, "notamark");
ok(false, "invalid measure end time exception not thrown!");
} catch (e) {
ok(e instanceof DOMException, "DOM exception thrown for invalid measure");
is(e.code, e.SYNTAX_ERR, "DOM exception for invalid time is syntax error");
}
},
// Test measure name being same as navigation timing parameter
function () {
ok(true, "Running measure name collision test");
for (n in performance.timing) {
try {
if (n == "toJSON") {
ok(true, "Skipping toJSON entry in collision test");
continue;
}
performance.measure(n);
ok(false, "Measure name collision test failed for name " + n + ", shouldn't make it here!");
} catch (e) {
ok(e instanceof DOMException, "DOM exception thrown for measure named " + n);
is(e.code, e.SYNTAX_ERR, "DOM exception for name collision is syntax error");
}
};
},
// Test measure mark being a reserved name
function () {
ok(true, "Create measures using all reserved names");
for (n in performance.timing) {
try {
if (n == "toJSON") {
ok(true, "Skipping toJSON entry in collision test");
continue;
}
performance.measure("test", n);
ok(true, "Measure created from reserved name as starting time: " + n);
} catch (e) {
ok(["redirectStart", "redirectEnd", "unloadEventStart", "unloadEventEnd", "loadEventEnd"].indexOf(n) >= 0,
"Measure created from reserved name as starting time: " + n + " and threw expected error");
}
};
},
function () {
ok(true, "all done!");
SimpleTest.finish();
}
// TODO: Test measure picking latest version of similarly named tags
];
function next() {
ok(true, "Begin!");
var arr;
for (var i = 0; i < steps.length; ++i) {
try {
performance.clearMarks();
performance.clearMeasures();
performance.clearResourceTimings();
arr = performance.getEntries();
is(arr.length, 0, "clearing performance entries");
steps[i]();
} catch(ex) {
ok(false, "Caught exception", ex);
}
}
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(next);
</script>
</pre>
</body>
</html>

View File

@ -859,10 +859,6 @@ var interfaceNamesInGlobalScope =
"Performance",
// IMPORTANT: Do not change this list without review from a DOM peer!
"PerformanceEntry",
// IMPORTANT: Do not change this list without review from a DOM peer!
"PerformanceMark",
// IMPORTANT: Do not change this list without review from a DOM peer!
"PerformanceMeasure",
// IMPORTANT: Do not change this list without review from a DOM peer!
"PerformanceNavigation",
// IMPORTANT: Do not change this list without review from a DOM peer!

View File

@ -51,16 +51,3 @@ partial interface Performance {
[Pref="dom.enable_resource_timing"]
attribute EventHandler onresourcetimingbufferfull;
};
// http://www.w3.org/TR/user-timing/
[Exposed=Window]
partial interface Performance {
[Pref="dom.enable_user_timing", Throws]
void mark(DOMString markName);
[Pref="dom.enable_user_timing"]
void clearMarks(optional DOMString markName);
[Pref="dom.enable_user_timing", Throws]
void measure(DOMString measureName, optional DOMString startMark, optional DOMString endMark);
[Pref="dom.enable_user_timing"]
void clearMeasures(optional DOMString measureName);
};

View File

@ -1,12 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/user-timing/#performancemark
*/
interface PerformanceMark : PerformanceEntry
{
};

View File

@ -1,12 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* http://www.w3.org/TR/user-timing/#performancemeasure
*/
interface PerformanceMeasure : PerformanceEntry
{
};

View File

@ -320,8 +320,6 @@ WEBIDL_FILES = [
'ParentNode.webidl',
'Performance.webidl',
'PerformanceEntry.webidl',
'PerformanceMark.webidl',
'PerformanceMeasure.webidl',
'PerformanceNavigation.webidl',
'PerformanceResourceTiming.webidl',
'PerformanceTiming.webidl',

View File

@ -144,9 +144,6 @@ pref("dom.enable_performance", true);
// Whether resource timing will be gathered and returned by performance.GetEntries*
pref("dom.enable_resource_timing", true);
// Enable high-resolution timing markers for users
pref("dom.enable_user_timing", true);
// Whether the Gamepad API is enabled
pref("dom.gamepad.enabled", true);
#ifdef RELEASE_BUILD

View File

@ -0,0 +1,62 @@
[idlharness.html]
type: testharness
[Performance interface: operation mark(DOMString)]
expected: FAIL
[Performance interface: operation clearMarks(DOMString)]
expected: FAIL
[Performance interface: operation measure(DOMString,DOMString,DOMString)]
expected: FAIL
[Performance interface: operation clearMeasures(DOMString)]
expected: FAIL
[Performance interface: window.performance must inherit property "mark" with the proper type (0)]
expected: FAIL
[Performance interface: calling mark(DOMString) on window.performance with too few arguments must throw TypeError]
expected: FAIL
[Performance interface: window.performance must inherit property "clearMarks" with the proper type (1)]
expected: FAIL
[Performance interface: calling clearMarks(DOMString) on window.performance with too few arguments must throw TypeError]
expected: FAIL
[Performance interface: window.performance must inherit property "measure" with the proper type (2)]
expected: FAIL
[Performance interface: calling measure(DOMString,DOMString,DOMString) on window.performance with too few arguments must throw TypeError]
expected: FAIL
[Performance interface: window.performance must inherit property "clearMeasures" with the proper type (3)]
expected: FAIL
[Performance interface: calling clearMeasures(DOMString) on window.performance with too few arguments must throw TypeError]
expected: FAIL
[PerformanceMark interface: existence and properties of interface object]
expected: FAIL
[PerformanceMark interface object length]
expected: FAIL
[PerformanceMark interface: existence and properties of interface prototype object]
expected: FAIL
[PerformanceMark interface: existence and properties of interface prototype object\'s "constructor" property]
expected: FAIL
[PerformanceMeasure interface: existence and properties of interface object]
expected: FAIL
[PerformanceMeasure interface object length]
expected: FAIL
[PerformanceMeasure interface: existence and properties of interface prototype object]
expected: FAIL
[PerformanceMeasure interface: existence and properties of interface prototype object\'s "constructor" property]
expected: FAIL

View File

@ -0,0 +1,5 @@
[test_user_timing_clear_marks.html]
type: testharness
[The User Timing and Performance Timeline interfaces, which are required for this test, are defined.]
expected: FAIL

View File

@ -0,0 +1,5 @@
[test_user_timing_clear_measures.html]
type: testharness
[The User Timing and Performance Timeline interfaces, which are required for this test, are defined.]
expected: FAIL

View File

@ -0,0 +1,3 @@
[test_user_timing_entry_type.html]
type: testharness
expected: ERROR

View File

@ -0,0 +1,14 @@
[test_user_timing_exists.html]
type: testharness
[window.performance.mark is defined.]
expected: FAIL
[window.performance.clearMarks is defined.]
expected: FAIL
[window.performance.measure is defined.]
expected: FAIL
[window.performance.clearMeasures is defined.]
expected: FAIL

View File

@ -1,4 +1,5 @@
[test_user_timing_mark.html]
type: testharness
disabled:
if (os == "win"): https://bugzilla.mozilla.org/show_bug.cgi?id=1127392
[The User Timing and Performance Timeline interfaces, which are required for this test, are defined.]
expected: FAIL

View File

@ -0,0 +1,8 @@
[test_user_timing_mark_and_measure_exception_when_invoke_without_parameter.html]
type: testharness
[window.performance.mark() interface is not supported!]
expected: FAIL
[window.performance.measure() interface is not supported!]
expected: FAIL

View File

@ -0,0 +1,5 @@
[test_user_timing_mark_exceptions.html]
type: testharness
[The User Timing and Performance Timeline interfaces, which are required for this test, are defined.]
expected: FAIL

View File

@ -0,0 +1,5 @@
[test_user_timing_measure.html]
type: testharness
[The User Timing and Performance Timeline interfaces, which are required for this test, are defined.]
expected: FAIL

View File

@ -0,0 +1,5 @@
[test_user_timing_measure_exceptions.html]
type: testharness
[The User Timing and Performance Timeline interfaces, which are required for this test, are defined.]
expected: FAIL

View File

@ -0,0 +1,5 @@
[test_user_timing_measure_navigation_timing.html]
type: testharness
[The User Timing and Performance Timeline interfaces, which are required for this test, are defined.]
expected: FAIL