Bug 694612. Hook up the performance timing APIs even inside an <object>. r=bzbarsky

This commit is contained in:
Igor Bazarny 2011-11-17 10:24:03 +13:00
parent e851f37192
commit d1283e88fa
3 changed files with 34 additions and 6 deletions

View File

@ -665,6 +665,11 @@ DispatchPings(nsIContent *content, nsIURI *referrer)
static nsDOMPerformanceNavigationType
ConvertLoadTypeToNavigationType(PRUint32 aLoadType)
{
// Not initialized, assume it's normal load.
if (aLoadType == 0) {
aLoadType = LOAD_NORMAL;
}
nsDOMPerformanceNavigationType result = nsIDOMPerformanceNavigation::TYPE_RESERVED;
switch (aLoadType) {
case LOAD_NORMAL:
@ -5874,12 +5879,7 @@ nsDocShell::OnStateChange(nsIWebProgress * aProgress, nsIRequest * aRequest,
channel->GetURI(getter_AddRefs(uri));
nsCAutoString aURI;
uri->GetAsciiSpec(aURI);
// If load type is not set, this is not a 'normal' load.
// No need to collect timing.
if (mLoadType == 0) {
mTiming = nsnull;
}
else if (this == aProgress){
if (this == aProgress){
rv = MaybeInitTiming();
if (mTiming) {
mTiming->NotifyFetchStart(uri, ConvertLoadTypeToNavigationType(mLoadType));

View File

@ -124,6 +124,7 @@ _TEST_FILES = \
file_bug680257.html \
test_bug691547.html \
bug691547_frame.html \
test_bug694612.html \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)

View File

@ -0,0 +1,27 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=694612
-->
<head>
<title>Test for Bug 694612</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=694612">Mozilla Bug 694612</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 694612 **/
SimpleTest.waitForExplicitFinish();
</script>
<object type="text/html"
data="data:text/html,<script>parent.isnot(performance, null, 'should have performance API in an <object>'); parent.SimpleTest.finish();</script>">
</object>
</pre>
</body>
</html>