Source/WebCore: [Resource Timing]Implementation of resource timing buffer size...

Source/WebCore: [Resource Timing]Implementation of resource timing buffer size restriction functionality
https://bugs.webkit.org/show_bug.cgi?id=84885.

Patch by Pan Deng <pan.deng@intel.com> on 2012-10-18
Reviewed by Tony Gentilcore.

http://www.w3.org/TR/2012/CR-resource-timing-20120522/
This patch enable functionality of set buffer size(default is 150 as spec). When buffer is full, resourceTimingBufferFull event will be fired. Incoming entries will be dropped if no more space for them.

Tests: http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_full_when_populate_entries.html
       http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_full_when_shrink_buffer_size.html
       http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_size_restriction.html
       http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_clear_resource_timing_functionality.html
       http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_on_shrink_buffer_size.html
       http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_store_and_clear_during_callback.html

* page/Performance.cpp:
(WebCore):
(WebCore::Performance::Performance):
(WebCore::Performance::webkitSetResourceTimingBufferSize):
(WebCore::Performance::addResourceTiming):
(WebCore::Performance::isResourceTimingBufferFull):
* page/Performance.h:
(Performance):

LayoutTests: [Resource Timing]Test cases for set buffer size functionality and event when buffer full.
https://bugs.webkit.org/show_bug.cgi?id=84885.

Patch by Pan Deng <pan.deng@intel.com> on 2012-10-18
Reviewed by Tony Gentilcore.

Test cases in this patch validate buffer size restriction functionality, clear resource timing functionality and the fired event when buffer full.

* http/tests/w3c/webperf/resources/webperftestharnessextension.js:
(PerformanceContext.prototype.getEntriesByName):
(PerformanceContext.prototype.setResourceTimingBufferSize):
(PerformanceContext.prototype.registerResourceTimingBufferFullCallback):
(PerformanceContext.prototype.clearResourceTimings):
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_full_when_populate_entries-expected.txt: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_full_when_populate_entries.html: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_full_when_shrink_buffer_size-expected.txt: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_full_when_shrink_buffer_size.html: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_size_restriction-expected.txt: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_size_restriction.html: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_clear_resource_timing_functionality-expected.txt: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_clear_resource_timing_functionality.html: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_on_shrink_buffer_size-expected.txt: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_on_shrink_buffer_size.html: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_store_and_clear_during_callback-expected.txt: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_store_and_clear_during_callback.html: Added.
* platform/chromium/TestExpectations:
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt-5.0-wk2/TestExpectations:
* platform/qt/TestExpectations:
* platform/win/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131829 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f308fd71
2012-10-18 Pan Deng <pan.deng@intel.com>
[Resource Timing]Test cases for set buffer size functionality and event when buffer full.
https://bugs.webkit.org/show_bug.cgi?id=84885.
Reviewed by Tony Gentilcore.
Test cases in this patch validate buffer size restriction functionality, clear resource timing functionality and the fired event when buffer full.
* http/tests/w3c/webperf/resources/webperftestharnessextension.js:
(PerformanceContext.prototype.getEntriesByName):
(PerformanceContext.prototype.setResourceTimingBufferSize):
(PerformanceContext.prototype.registerResourceTimingBufferFullCallback):
(PerformanceContext.prototype.clearResourceTimings):
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_full_when_populate_entries-expected.txt: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_full_when_populate_entries.html: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_full_when_shrink_buffer_size-expected.txt: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_full_when_shrink_buffer_size.html: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_size_restriction-expected.txt: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_size_restriction.html: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_clear_resource_timing_functionality-expected.txt: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_clear_resource_timing_functionality.html: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_on_shrink_buffer_size-expected.txt: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_on_shrink_buffer_size.html: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_store_and_clear_during_callback-expected.txt: Added.
* http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_store_and_clear_during_callback.html: Added.
* platform/chromium/TestExpectations:
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt-5.0-wk2/TestExpectations:
* platform/qt/TestExpectations:
* platform/win/TestExpectations:
2012-10-18 Ryosuke Niwa <rniwa@webkit.org>
REGRESSION(r130411): Copying & pasting the first line of text can move caret to the end of text area
......
......@@ -174,6 +174,40 @@ PerformanceContext.prototype =
this.performanceContext.oGetEntriesByName ||
this.performanceContext.webkitGetEntriesByName)
.apply(this.performanceContext, arguments);
},
setResourceTimingBufferSize: function()
{
return (this.performanceContext.setResourceTimingBufferSize ||
this.performanceContext.mozSetResourceTimingBufferSize ||
this.performanceContext.msSetResourceTimingBufferSize ||
this.performanceContext.oSetResourceTimingBufferSize ||
this.performanceContext.webkitSetResourceTimingBufferSize)
.apply(this.performanceContext, arguments);
},
registerResourceTimingBufferFullCallback: function(func)
{
if (typeof this.performanceContext.onresourcetimingbufferfull !== "undefined")
this.performanceContext.onresourcetimingbufferfull = func;
else if (typeof this.performanceContext.onmozresourcetimingbufferfull !== "undefined")
this.performanceContext.onmozresourcetimingbufferfull = func;
else if (typeof this.performanceContext.onmsresourcetimingbufferfull !== "undefined")
this.performanceContext.onmsresourcetimingbufferfull = func;
else if (typeof this.performanceContext.onoresourcetimingbufferfull !== "undefined")
this.performanceContext.onoresourcetimingbufferfull = func;
else if (typeof this.performanceContext.onwebkitresourcetimingbufferfull !== "undefined")
this.performanceContext.onwebkitresourcetimingbufferfull = func;
},
clearResourceTimings: function()
{
(this.performanceContext.clearResourceTimings ||
this.performanceContext.mozClearResourceTimings ||
this.performanceContext.msClearResourceTimings ||
this.performanceContext.oClearResourceTimings ||
this.performanceContext.webkitClearResourceTimings)
.apply(this.performanceContext, arguments);
}
};
Description
This test validates the functionality of onresourcetimingbufferfull in resource timing.
PASS onresourcetimingbufferfull should have been invoked once buffer is full!
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>onresourcetimingbufferfull callback of resource timing</title>
<script src="/w3c/webperf/resources/webperftestharnessextension.js"></script>
<script>
var context = new PerformanceContext(performance);
var count = 0;
function buffer_full_call_back()
{
count++;
}
context.registerResourceTimingBufferFullCallback(buffer_full_call_back);
context.setResourceTimingBufferSize(2);
</script>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
<script src="/w3c/resources/testharness.js"></script>
<script src="/w3c/resources/testharnessreport.js"></script>
<script src="/w3c/webperf/resources/webperftestharness.js"></script>
<script>
setup({ explicit_done: true });
function onload_test()
{
test_equals(count, 1, "onresourcetimingbufferfull should have been invoked once buffer is full!");
done();
}
</script>
</head>
<body onload=onload_test()>
<h1>Description</h1>
<p>This test validates the functionality of onresourcetimingbufferfull in resource timing.</p>
</body>
</html>
Description
This test validates the functionality of onresourcetimingbufferfull in resource timing.
PASS onresourcetimingbufferfull should be invoked once the buffer is shrunk to size which is less than or equal to current entry number!
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>onresourcetimingbufferfull callback of resource timing</title>
<script src="/w3c/webperf/resources/webperftestharnessextension.js"></script>
<script>
var context = new PerformanceContext(performance);
var count = 0;
function buffer_full_call_back()
{
count++;
}
context.registerResourceTimingBufferFullCallback(buffer_full_call_back);
</script>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
<script src="/w3c/resources/testharness.js"></script>
<script src="/w3c/resources/testharnessreport.js"></script>
<script src="/w3c/webperf/resources/webperftestharness.js"></script>
<script>
setup({ explicit_done: true });
function onload_test()
{
context.setResourceTimingBufferSize(3);
context.setResourceTimingBufferSize(2);
test_equals(count, 2, "onresourcetimingbufferfull should be invoked once the buffer is shrunk to size which is less than or equal to current entry number!");
done();
}
</script>
</head>
<body onload=onload_test()>
<h1>Description</h1>
<p>This test validates the functionality of onresourcetimingbufferfull in resource timing.</p>
</body>
</html>
Description
This test validates the functionality of setResourceTimingBufferSize method in resource timing.
PASS 2 resource timing entries should be stored since buffer size is 2!
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>buffer size restriction functionality of resource timing</title>
<script src="/w3c/webperf/resources/webperftestharnessextension.js"></script>
<script>
var context = new PerformanceContext(performance);
var buffer_size = 2;
context.setResourceTimingBufferSize(buffer_size);
</script>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
<script src="/w3c/resources/testharness.js"></script>
<script src="/w3c/resources/testharnessreport.js"></script>
<script src="/w3c/webperf/resources/webperftestharness.js"></script>
<script>
setup({ explicit_done: true });
function onload_test()
{
test_equals(context.getEntriesByType("resource").length, buffer_size, buffer_size + " resource timing entries should be stored since buffer size is " + buffer_size + "!");
done();
}
</script>
</head>
<body onload=onload_test()>
<h1>Description</h1>
<p>This test validates the functionality of setResourceTimingBufferSize method in resource timing.</p>
</body>
</html>
Description
This test validates the functionality of clearResourceTimings method in resource timing.
PASS 4 resource timing entries should be stored in this page!
PASS No resource timing entries should be stored after clearResourceTimings!
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>clearResourceTimings functionality of resource timing</title>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
<script src="/w3c/resources/testharness.js"></script>
<script src="/w3c/resources/testharnessreport.js"></script>
<script src="/w3c/webperf/resources/webperftestharness.js"></script>
<script src="/w3c/webperf/resources/webperftestharnessextension.js"></script>
<script>
setup({ explicit_done: true });
var context = new PerformanceContext(performance);
function onload_test()
{
test_equals(context.getEntriesByType("resource").length, 4, 4 + " resource timing entries should be stored in this page!");
context.clearResourceTimings();
test_equals(context.getEntriesByType("resource").length, 0, "No resource timing entries should be stored after clearResourceTimings!");
done();
}
</script>
</head>
<body onload=onload_test()>
<h1>Description</h1>
<p>This test validates the functionality of clearResourceTimings method in resource timing.</p>
</body>
</html>
Description
This test validates the behavior of shrink resource timing buffer size.
PASS There should be entries in resource timing buffer!
PASS Resource timing buffer should never been changed even buffer size is shrunk!
PASS There should be no entries in resource timing buffer after clearResourceTimings
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>shrink resource timing buffer size</title>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
<script src="/w3c/resources/testharness.js"></script>
<script src="/w3c/resources/testharnessreport.js"></script>
<script src="/w3c/webperf/resources/webperftestharness.js"></script>
<script src="/w3c/webperf/resources/webperftestharnessextension.js"></script>
<script>
setup({ explicit_done: true });
var context = new PerformanceContext(performance);
function onload_test()
{
var entry_list_before_shrink = context.getEntriesByType('resource');
context.setResourceTimingBufferSize(0);
var entry_list_after_shrink = context.getEntriesByType('resource');
test_greater_than(entry_list_before_shrink.length, 0, "There should be entries in resource timing buffer!");
test_equals(JSON.stringify(entry_list_before_shrink), JSON.stringify(entry_list_after_shrink), "Resource timing buffer should never been changed even buffer size is shrunk!");
context.clearResourceTimings();
test_equals(context.getEntriesByType('resource').length, 0, "There should be no entries in resource timing buffer after clearResourceTimings");
done();
}
</script>
</head>
<body onload=onload_test()>
<h1>Description</h1>
<p>This test validates the behavior of shrink resource timing buffer size.</p>
</body>
</html>
Description
This test validates the behavior of read and clear operation in onresourcetimingbufferfull callback of resource timing.
PASS No entry should be stored in resource timing buffer since it's cleared once an item arrived!
PASS 4 resource timing entries should be moved to global buffer!
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>read and clear resource timing entry in onresourcetimingbufferfull callback</title>
<script src="/w3c/webperf/resources/webperftestharnessextension.js"></script>
<script>
var context = new PerformanceContext(performance);
var resource_timing_buffer_size = 1;
var global_buffer = [];
function store_and_clear()
{
var entry_list = context.getEntriesByType('resource');
for (var i = 0; i < entry_list.length; ++i)
global_buffer.push(entry_list[i]);
context.clearResourceTimings();
}
context.registerResourceTimingBufferFullCallback(store_and_clear);
context.setResourceTimingBufferSize(resource_timing_buffer_size);
</script>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
<script src="/w3c/resources/testharness.js"></script>
<script src="/w3c/resources/testharnessreport.js"></script>
<script src="/w3c/webperf/resources/webperftestharness.js"></script>
<script>
setup({ explicit_done: true });
function onload_test()
{
test_equals(context.getEntriesByType('resource').length, 0, "No entry should be stored in resource timing buffer since it's cleared once an item arrived!");
test_equals(global_buffer.length, 4, "4 resource timing entries should be moved to global buffer!");
done();
}
</script>
</head>
<body onload=onload_test()>
<h1>Description</h1>
<p>This test validates the behavior of read and clear operation in onresourcetimingbufferfull callback of resource timing.</p>
</body>
</html>
......@@ -4230,3 +4230,6 @@ webkit.org/b/84893 http/tests/w3c/webperf/submission/Intel/user-timing [ Skip ]
# Expected to fail until WebGL extension implementation lands
webkit.org/b/98257 fast/canvas/webgl/oes-element-index-uint.html [ Failure Pass ]
webkit.org/b/98257 platform/chromium/virtual/gpu/fast/canvas/webgl/oes-element-index-uint.html [ Failure Pass ]
# Resource Timing is not enable yet, skip it.
webkit.org/b/61138 http/tests/w3c/webperf/submission/Intel/resource-timing [ Skip ]
......@@ -2060,3 +2060,6 @@ webkit.org/b/84893 http/tests/w3c/webperf/submission/Intel/user-timing [ Skip ]
# Regression after r131640.
webkit.org/b/99691 gamepad/gamepad-out-of-range-crasher.html [ Failure ]
# Resource Timing is not enable yet, skip it.
webkit.org/b/61138 http/tests/w3c/webperf/submission/Intel/resource-timing [ Skip ]
......@@ -1382,6 +1382,9 @@ webkit.org/b/98950 transitions/blendmode-transitions.html [ Failure ]
# User Timing is not enable yet. so skip it.
webkit.org/b/84893 http/tests/w3c/webperf/submission/Intel/user-timing [ Skip ]
# Resource Timing is not enable yet, skip it.
webkit.org/b/61138 http/tests/w3c/webperf/submission/Intel/resource-timing [ Skip ]
#////////////////////////////////////////////////////////////////////////////////////////
# End of Tests failing
#////////////////////////////////////////////////////////////////////////////////////////
......@@ -1320,3 +1320,6 @@ webkit.org/b/84893 http/tests/w3c/webperf/submission/Intel/user-timing [ Skip ]
# Expected to fail until WebGL extension implementation lands
webkit.org/b/98257 fast/canvas/webgl/oes-element-index-uint.html [ Failure Pass ]
# Resource Timing is not enable yet, skip it.
webkit.org/b/61138 http/tests/w3c/webperf/submission/Intel/resource-timing [ Skip ]
......@@ -618,3 +618,6 @@ webkit.org/b/99155 http/tests/navigation/ping-cross-origin-from-https.html
# User Timing is not enabled
webkit.org/b/84893 http/tests/w3c/webperf/proposal/Intel/user-timing
# Resource Timing is not enable yet, skip it.
webkit.org/b/61138 http/tests/w3c/webperf/submission/Intel/resource-timing
......@@ -591,6 +591,9 @@ fast/dom/Geolocation/coordinates-interface-attributes.html
# User Timing is not enabled
webkit.org/b/84893 http/tests/w3c/webperf/submission/Intel/user-timing
# Resource Timing is not enable yet, skip it.
webkit.org/b/61138 http/tests/w3c/webperf/submission/Intel/resource-timing
# =========================================================================== #
# Drag and Drop Support in DRT. #
# =========================================================================== #
......
......@@ -2348,3 +2348,6 @@ transitions/blendmode-transitions.html
# User Timing is not enabled
webkit.org/b/84893 http/tests/w3c/webperf/submission/Intel/user-timing
# Resource Timing is not enable yet, skip it.
webkit.org/b/61138 http/tests/w3c/webperf/submission/Intel/resource-timing
2012-10-18 Pan Deng <pan.deng@intel.com>
[Resource Timing]Implementation of resource timing buffer size restriction functionality
https://bugs.webkit.org/show_bug.cgi?id=84885.
Reviewed by Tony Gentilcore.
http://www.w3.org/TR/2012/CR-resource-timing-20120522/
This patch enable functionality of set buffer size(default is 150 as spec). When buffer is full, resourceTimingBufferFull event will be fired. Incoming entries will be dropped if no more space for them.
Tests: http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_full_when_populate_entries.html
http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_full_when_shrink_buffer_size.html
http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_buffer_size_restriction.html
http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_clear_resource_timing_functionality.html
http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_on_shrink_buffer_size.html
http/tests/w3c/webperf/submission/Intel/resource-timing/test_resource_timing_store_and_clear_during_callback.html
* page/Performance.cpp:
(WebCore):
(WebCore::Performance::Performance):
(WebCore::Performance::webkitSetResourceTimingBufferSize):
(WebCore::Performance::addResourceTiming):
(WebCore::Performance::isResourceTimingBufferFull):
* page/Performance.h:
(Performance):
2012-10-18 Ryosuke Niwa <rniwa@webkit.org>
REGRESSION(r130411): Copying & pasting the first line of text can move caret to the end of text area
......
......@@ -49,8 +49,15 @@
namespace WebCore {
#if ENABLE(RESOURCE_TIMING)
static const size_t defaultResourceTimingBufferSize = 150;
#endif
Performance::Performance(Frame* frame)
: DOMWindowProperty(frame)
#if ENABLE(RESOURCE_TIMING)
, m_resourceTimingBufferSize(defaultResourceTimingBufferSize)
#endif
{
}
......@@ -143,19 +150,29 @@ void Performance::webkitClearResourceTimings()
m_resourceTimingBuffer.clear();
}
void Performance::webkitSetResourceTimingBufferSize(unsigned int)
void Performance::webkitSetResourceTimingBufferSize(unsigned size)
{
// FIXME: Implement this.
m_resourceTimingBufferSize = size;
if (isResourceTimingBufferFull())
dispatchEvent(Event::create(eventNames().webkitresourcetimingbufferfullEvent, false, false));
}
void Performance::addResourceTiming(const ResourceRequest& request, const ResourceResponse& response, double finishTime, Document* requestingDocument)
{
if (!response.resourceLoadTiming())
if (!response.resourceLoadTiming() || isResourceTimingBufferFull())
return;
RefPtr<PerformanceEntry> entry = PerformanceResourceTiming::create(request, response, finishTime, requestingDocument);
// FIXME: Need to enforce buffer limits.
m_resourceTimingBuffer.append(entry);
if (isResourceTimingBufferFull())
dispatchEvent(Event::create(eventNames().webkitresourcetimingbufferfullEvent, false, false));
}
bool Performance::isResourceTimingBufferFull()
{
return m_resourceTimingBuffer.size() >= m_resourceTimingBufferSize;
}
#endif // ENABLE(RESOURCE_TIMING)
......
......@@ -100,6 +100,7 @@ private:
virtual void derefEventTarget() { deref(); }
virtual EventTargetData* eventTargetData();
virtual EventTargetData* ensureEventTargetData();
bool isResourceTimingBufferFull();
EventTargetData m_eventTargetData;
......@@ -108,6 +109,7 @@ private:
#if ENABLE(RESOURCE_TIMING)
Vector<RefPtr<PerformanceEntry> > m_resourceTimingBuffer;
unsigned m_resourceTimingBufferSize;
#endif
#if ENABLE(USER_TIMING)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment