JSDocument::setLocation does too much bare-handed lifting
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Apr 2012 08:57:33 +0000 (08:57 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Apr 2012 08:57:33 +0000 (08:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83850

Reviewed by Sam Weinig.

As part of auditing all the ways of kicking off a navigation, I
happened to read JSDocument::setLocation, which uses very old patterns.
This patch updates it to do things the "modern" way.  There shouldn't
be any behavior change.

* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::setLocation):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114098 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDocumentCustom.cpp

index b24ebe1..09b63c4 100644 (file)
@@ -1,3 +1,18 @@
+2012-04-13  Adam Barth  <abarth@webkit.org>
+
+        JSDocument::setLocation does too much bare-handed lifting
+        https://bugs.webkit.org/show_bug.cgi?id=83850
+
+        Reviewed by Sam Weinig.
+
+        As part of auditing all the ways of kicking off a navigation, I
+        happened to read JSDocument::setLocation, which uses very old patterns.
+        This patch updates it to do things the "modern" way.  There shouldn't
+        be any behavior change.
+
+        * bindings/js/JSDocumentCustom.cpp:
+        (WebCore::JSDocument::setLocation):
+
 2012-04-13  Shinya Kawanaka  <shinyak@chromium.org>
 
         Background width (or height) is wrong if width (or height) * zoom < 1.
index 8377a09..b6de162 100644 (file)
@@ -69,18 +69,12 @@ void JSDocument::setLocation(ExecState* exec, JSValue value)
     if (!frame)
         return;
 
-    String str = ustringToString(value.toString(exec)->value(exec));
-
-    Frame* lexicalFrame = asJSDOMWindow(exec->lexicalGlobalObject())->impl()->frame();
-
-    // IE and Mozilla both resolve the URL relative to the source frame,
-    // not the target frame.
-    Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame();
-    str = activeFrame->document()->completeURL(str).string();
+    UString locationString = value.toString(exec)->value(exec);
+    if (exec->hadException())
+        return;
 
-    bool lockHistory = !ScriptController::processingUserGesture();
-    frame->navigationScheduler()->scheduleLocationChange(lexicalFrame->document()->securityOrigin(),
-        str, activeFrame->loader()->outgoingReferrer(), lockHistory, false);
+    if (Location* location = frame->domWindow()->location())
+        location->setHref(ustringToString(locationString), activeDOMWindow(exec), firstDOMWindow(exec));
 }
 
 JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Document* document)