mirror of https://github.com/vitalif/phantomjs
Fix window.location.
Description: Web Page can't navigate to a relative url using the property 'window.location'. Upstream bug: https://bugs.webkit.org/show_bug.cgi?id=47978 Issues: http://code.google.com/p/phantomjs/issues/detail?id=632 http://code.google.com/p/phantomjs/issues/detail?id=5301.8
parent
31dd714a22
commit
5eb0f64e6b
|
@ -445,14 +445,14 @@ DynamicGlobalObjectScope::DynamicGlobalObjectScope(JSGlobalData& globalData, JSG
|
||||||
: m_dynamicGlobalObjectSlot(globalData.dynamicGlobalObject)
|
: m_dynamicGlobalObjectSlot(globalData.dynamicGlobalObject)
|
||||||
, m_savedDynamicGlobalObject(m_dynamicGlobalObjectSlot)
|
, m_savedDynamicGlobalObject(m_dynamicGlobalObjectSlot)
|
||||||
{
|
{
|
||||||
if (!m_dynamicGlobalObjectSlot) {
|
|
||||||
#if ENABLE(ASSEMBLER)
|
#if ENABLE(ASSEMBLER)
|
||||||
if (ExecutableAllocator::underMemoryPressure())
|
if (ExecutableAllocator::underMemoryPressure())
|
||||||
globalData.recompileAllJSFunctions();
|
globalData.recompileAllJSFunctions();
|
||||||
#endif
|
#endif
|
||||||
|
bool slotWasEmpty = !m_dynamicGlobalObjectSlot;
|
||||||
|
m_dynamicGlobalObjectSlot = dynamicGlobalObject;
|
||||||
|
|
||||||
m_dynamicGlobalObjectSlot = dynamicGlobalObject;
|
if (slotWasEmpty) {
|
||||||
|
|
||||||
// Reset the date cache between JS invocations to force the VM
|
// Reset the date cache between JS invocations to force the VM
|
||||||
// to observe time zone changes.
|
// to observe time zone changes.
|
||||||
globalData.resetDateCache();
|
globalData.resetDateCache();
|
||||||
|
|
|
@ -178,14 +178,15 @@ protected:
|
||||||
navigationType = "Other";
|
navigationType = "Other";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
bool isNavigationLocked = m_webPage->navigationLocked();
|
||||||
|
|
||||||
emit m_webPage->navigationRequested(
|
emit m_webPage->navigationRequested(
|
||||||
request.url(), //< Requested URL
|
request.url(), //< Requested URL
|
||||||
navigationType, //< Navigation Type
|
navigationType, //< Navigation Type
|
||||||
!m_webPage->navigationLocked(), //< Is navigation locked?
|
!isNavigationLocked, //< Is navigation locked?
|
||||||
isMainFrame); //< Is main frame?
|
isMainFrame); //< Is main frame?
|
||||||
|
|
||||||
return !m_webPage->navigationLocked();
|
return !isNavigationLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWebPage *createWindow (WebWindowType type) {
|
QWebPage *createWindow (WebWindowType type) {
|
||||||
|
@ -551,7 +552,7 @@ QString WebPage::userAgent() const
|
||||||
|
|
||||||
void WebPage::setNavigationLocked(bool lock)
|
void WebPage::setNavigationLocked(bool lock)
|
||||||
{
|
{
|
||||||
m_navigationLocked = lock;;
|
m_navigationLocked = lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebPage::navigationLocked()
|
bool WebPage::navigationLocked()
|
||||||
|
|
|
@ -1595,3 +1595,39 @@ describe("WebPage 'onFilePicker'", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('WebPage navigation events', function() {
|
||||||
|
it('should navigate to relative url using window.location', function () {
|
||||||
|
var page = require("webpage").create();
|
||||||
|
var base = 'https://github.com';
|
||||||
|
var path = '/n1k0';
|
||||||
|
var expected = 'https://github.com/n1k0';
|
||||||
|
var isHandled = false;
|
||||||
|
|
||||||
|
runs(function() {
|
||||||
|
page.onNavigationRequested = function(url, navigationType, navigationLocked, isMainFrame) {
|
||||||
|
if (!page.testStarted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url === expected) {
|
||||||
|
isHandled = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
page.open(base, function(status) {
|
||||||
|
page.testStarted = true;
|
||||||
|
|
||||||
|
page.evaluate(function(path) {
|
||||||
|
window.location = path;
|
||||||
|
}, path);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
waits(10000);
|
||||||
|
|
||||||
|
runs(function() {
|
||||||
|
expect(isHandled).toEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue