diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index e0622aa74844..0601da08e94f 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -10493,6 +10493,9 @@ nsDocShell::InternalLoad(nsIURI* aURI, (aFlags & INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) != 0; mURIResultedInDocument = false; // reset the clock... + // Note that there is code that relies on this check to stop us entering the + // `doShortCircuitedLoad` block below for certain load types. (For example, + // reftest-content.js uses LOAD_FLAGS_BYPASS_CACHE for this purpose.) if (aLoadType == LOAD_NORMAL || aLoadType == LOAD_STOP_CONTENT || LOAD_TYPE_HAS_FLAGS(aLoadType, LOAD_FLAGS_REPLACE_HISTORY) || diff --git a/layout/tools/reftest/reftest-content.js b/layout/tools/reftest/reftest-content.js index b357629d6b51..edcebd4adec9 100644 --- a/layout/tools/reftest/reftest-content.js +++ b/layout/tools/reftest/reftest-content.js @@ -1055,9 +1055,35 @@ function DoAssertionCheck() SendAssertionCount(numAsserts); } +function URIsEqualIgnoringHash(uri1, uri2) +{ + let hashIndex1 = uri1.indexOf("#"); + if (hashIndex1 > -1) { + uri1 = uri1.substr(0, hashIndex1); + } + let hashIndex2 = uri2.indexOf("#"); + if (hashIndex2 > -1) { + uri2 = uri2.substr(0, hashIndex2); + } + return uri1 == uri2; +} + function LoadURI(uri) { - var flags = webNavigation().LOAD_FLAGS_NONE; + let flags = CI.nsIWebNavigation.LOAD_FLAGS_NONE; + + if (URIsEqualIgnoringHash(uri, gCurrentURL)) { + // In this case the new URI would normally just cause an anchor scroll + // so we use LOAD_FLAGS_BYPASS_CACHE to force a reload so we'll get a + // 'load' event. (The code that handles new URIs once they're ready is + // triggered by a 'load' event, so we'll time out if we don't get one). + // + // Note that we avoid using this flag in general since we don't want + // to unnecessarily reload and reprocess common font files, images, + // etc. for every test/reference (that may slow down reftest runs). + flags = CI.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE; + } + webNavigation().loadURI(uri, flags, null, null, null); }