2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include "DOMWindow.h"
30 #include "AbstractDatabase.h"
31 #include "BackForwardController.h"
34 #include "BeforeUnloadEvent.h"
35 #include "CSSComputedStyleDeclaration.h"
36 #include "CSSRuleList.h"
37 #include "CSSStyleSelector.h"
41 #include "DOMApplicationCache.h"
42 #include "DOMSelection.h"
43 #include "DOMSettableTokenList.h"
44 #include "DOMStringList.h"
46 #include "DOMTokenList.h"
49 #include "DatabaseCallback.h"
50 #include "DeviceMotionController.h"
51 #include "DeviceOrientationController.h"
53 #include "DocumentLoader.h"
55 #include "EventException.h"
56 #include "EventListener.h"
57 #include "EventNames.h"
58 #include "ExceptionCode.h"
59 #include "FloatRect.h"
61 #include "FrameLoadRequest.h"
62 #include "FrameLoader.h"
63 #include "FrameTree.h"
64 #include "FrameView.h"
65 #include "HTMLFrameOwnerElement.h"
67 #include "IDBFactory.h"
68 #include "IDBFactoryBackendInterface.h"
69 #include "InspectorInstrumentation.h"
72 #include "MediaQueryList.h"
73 #include "MediaQueryMatcher.h"
74 #include "MessageEvent.h"
75 #include "Navigator.h"
76 #include "NotificationCenter.h"
78 #include "PageGroup.h"
79 #include "PageTransitionEvent.h"
80 #include "Performance.h"
81 #include "PlatformScreen.h"
82 #include "PlatformString.h"
84 #include "SecurityOrigin.h"
85 #include "SerializedScriptValue.h"
88 #include "StorageArea.h"
89 #include "StorageNamespace.h"
90 #include "StyleMedia.h"
91 #include "SuddenTermination.h"
92 #include "WebKitPoint.h"
93 #include "WindowFeatures.h"
95 #include <wtf/CurrentTime.h>
96 #include <wtf/MathExtras.h>
97 #include <wtf/text/StringConcatenate.h>
99 #if ENABLE(FILE_SYSTEM)
100 #include "AsyncFileSystem.h"
101 #include "DOMFileSystem.h"
102 #include "DOMFileSystemBase.h"
103 #include "EntryCallback.h"
104 #include "ErrorCallback.h"
105 #include "FileError.h"
106 #include "FileSystemCallback.h"
107 #include "FileSystemCallbacks.h"
108 #include "LocalFileSystem.h"
111 #if ENABLE(REQUEST_ANIMATION_FRAME)
112 #include "RequestAnimationFrameCallback.h"
120 class PostMessageTimer : public TimerBase {
122 PostMessageTimer(DOMWindow* window, PassRefPtr<SerializedScriptValue> message, const String& sourceOrigin, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortChannelArray> channels, SecurityOrigin* targetOrigin)
125 , m_origin(sourceOrigin)
127 , m_channels(channels)
128 , m_targetOrigin(targetOrigin)
132 PassRefPtr<MessageEvent> event(ScriptExecutionContext* context)
134 OwnPtr<MessagePortArray> messagePorts = MessagePort::entanglePorts(*context, m_channels.release());
135 return MessageEvent::create(messagePorts.release(), m_message, m_origin, "", m_source);
137 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); }
142 m_window->postMessageTimerFired(this);
145 RefPtr<DOMWindow> m_window;
146 RefPtr<SerializedScriptValue> m_message;
148 RefPtr<DOMWindow> m_source;
149 OwnPtr<MessagePortChannelArray> m_channels;
150 RefPtr<SecurityOrigin> m_targetOrigin;
153 typedef HashCountedSet<DOMWindow*> DOMWindowSet;
155 static DOMWindowSet& windowsWithUnloadEventListeners()
157 DEFINE_STATIC_LOCAL(DOMWindowSet, windowsWithUnloadEventListeners, ());
158 return windowsWithUnloadEventListeners;
161 static DOMWindowSet& windowsWithBeforeUnloadEventListeners()
163 DEFINE_STATIC_LOCAL(DOMWindowSet, windowsWithBeforeUnloadEventListeners, ());
164 return windowsWithBeforeUnloadEventListeners;
167 static void addUnloadEventListener(DOMWindow* domWindow)
169 DOMWindowSet& set = windowsWithUnloadEventListeners();
171 disableSuddenTermination();
175 static void removeUnloadEventListener(DOMWindow* domWindow)
177 DOMWindowSet& set = windowsWithUnloadEventListeners();
178 DOMWindowSet::iterator it = set.find(domWindow);
183 enableSuddenTermination();
186 static void removeAllUnloadEventListeners(DOMWindow* domWindow)
188 DOMWindowSet& set = windowsWithUnloadEventListeners();
189 DOMWindowSet::iterator it = set.find(domWindow);
194 enableSuddenTermination();
197 static void addBeforeUnloadEventListener(DOMWindow* domWindow)
199 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
201 disableSuddenTermination();
205 static void removeBeforeUnloadEventListener(DOMWindow* domWindow)
207 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
208 DOMWindowSet::iterator it = set.find(domWindow);
213 enableSuddenTermination();
216 static void removeAllBeforeUnloadEventListeners(DOMWindow* domWindow)
218 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
219 DOMWindowSet::iterator it = set.find(domWindow);
224 enableSuddenTermination();
227 static bool allowsBeforeUnloadListeners(DOMWindow* window)
229 ASSERT_ARG(window, window);
230 Frame* frame = window->frame();
233 Page* page = frame->page();
236 return frame == page->mainFrame();
239 bool DOMWindow::dispatchAllPendingBeforeUnloadEvents()
241 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
245 static bool alreadyDispatched = false;
246 ASSERT(!alreadyDispatched);
247 if (alreadyDispatched)
250 Vector<RefPtr<DOMWindow> > windows;
251 DOMWindowSet::iterator end = set.end();
252 for (DOMWindowSet::iterator it = set.begin(); it != end; ++it)
253 windows.append(it->first);
255 size_t size = windows.size();
256 for (size_t i = 0; i < size; ++i) {
257 DOMWindow* window = windows[i].get();
258 if (!set.contains(window))
261 Frame* frame = window->frame();
265 if (!frame->loader()->shouldClose())
269 enableSuddenTermination();
271 alreadyDispatched = true;
276 unsigned DOMWindow::pendingUnloadEventListeners() const
278 return windowsWithUnloadEventListeners().count(const_cast<DOMWindow*>(this));
281 void DOMWindow::dispatchAllPendingUnloadEvents()
283 DOMWindowSet& set = windowsWithUnloadEventListeners();
287 static bool alreadyDispatched = false;
288 ASSERT(!alreadyDispatched);
289 if (alreadyDispatched)
292 Vector<RefPtr<DOMWindow> > windows;
293 DOMWindowSet::iterator end = set.end();
294 for (DOMWindowSet::iterator it = set.begin(); it != end; ++it)
295 windows.append(it->first);
297 size_t size = windows.size();
298 for (size_t i = 0; i < size; ++i) {
299 DOMWindow* window = windows[i].get();
300 if (!set.contains(window))
303 window->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, false), window->document());
304 window->dispatchEvent(Event::create(eventNames().unloadEvent, false, false), window->document());
307 enableSuddenTermination();
309 alreadyDispatched = true;
313 // 1) Validates the pending changes are not changing to NaN
314 // 2) Constrains the window rect to no smaller than 100 in each dimension and no
315 // bigger than the the float rect's dimensions.
316 // 3) Constrain window rect to within the top and left boundaries of the screen rect
317 // 4) Constraint the window rect to within the bottom and right boundaries of the
319 // 5) Translate the window rect coordinates to be within the coordinate space of
321 void DOMWindow::adjustWindowRect(const FloatRect& screen, FloatRect& window, const FloatRect& pendingChanges)
323 // Make sure we're in a valid state before adjusting dimensions.
324 ASSERT(isfinite(screen.x()));
325 ASSERT(isfinite(screen.y()));
326 ASSERT(isfinite(screen.width()));
327 ASSERT(isfinite(screen.height()));
328 ASSERT(isfinite(window.x()));
329 ASSERT(isfinite(window.y()));
330 ASSERT(isfinite(window.width()));
331 ASSERT(isfinite(window.height()));
333 // Update window values if new requested values are not NaN.
334 if (!isnan(pendingChanges.x()))
335 window.setX(pendingChanges.x());
336 if (!isnan(pendingChanges.y()))
337 window.setY(pendingChanges.y());
338 if (!isnan(pendingChanges.width()))
339 window.setWidth(pendingChanges.width());
340 if (!isnan(pendingChanges.height()))
341 window.setHeight(pendingChanges.height());
343 // Resize the window to between 100 and the screen width and height.
344 window.setWidth(min(max(100.0f, window.width()), screen.width()));
345 window.setHeight(min(max(100.0f, window.height()), screen.height()));
347 // Constrain the window position to the screen.
348 window.setX(max(screen.x(), min(window.x(), screen.maxX() - window.width())));
349 window.setY(max(screen.y(), min(window.y(), screen.maxY() - window.height())));
352 // FIXME: We can remove this function once V8 showModalDialog is changed to use DOMWindow.
353 void DOMWindow::parseModalDialogFeatures(const String& string, HashMap<String, String>& map)
355 WindowFeatures::parseDialogFeatures(string, map);
358 bool DOMWindow::allowPopUp(Frame* firstFrame)
362 if (ScriptController::processingUserGesture())
365 Settings* settings = firstFrame->settings();
366 return settings && settings->javaScriptCanOpenWindowsAutomatically();
369 bool DOMWindow::allowPopUp()
371 return m_frame && allowPopUp(m_frame);
374 bool DOMWindow::canShowModalDialog(const Frame* frame)
378 Page* page = frame->page();
381 return page->chrome()->canRunModal();
384 bool DOMWindow::canShowModalDialogNow(const Frame* frame)
388 Page* page = frame->page();
391 return page->chrome()->canRunModalNow();
394 DOMWindow::DOMWindow(Frame* frame)
395 : m_shouldPrintWhenFinishedLoading(false)
400 DOMWindow::~DOMWindow()
403 m_frame->clearFormerDOMWindow(this);
405 removeAllUnloadEventListeners(this);
406 removeAllBeforeUnloadEventListeners(this);
409 ScriptExecutionContext* DOMWindow::scriptExecutionContext() const
414 PassRefPtr<MediaQueryList> DOMWindow::matchMedia(const String& media)
416 return document() ? document()->mediaQueryMatcher()->matchMedia(media) : 0;
419 void DOMWindow::disconnectFrame()
425 void DOMWindow::clear()
428 m_screen->disconnectFrame();
432 m_selection->disconnectFrame();
436 m_history->disconnectFrame();
442 m_locationbar->disconnectFrame();
446 m_menubar->disconnectFrame();
450 m_personalbar->disconnectFrame();
454 m_scrollbars->disconnectFrame();
458 m_statusbar->disconnectFrame();
462 m_toolbar->disconnectFrame();
466 m_console->disconnectFrame();
470 m_navigator->disconnectFrame();
473 #if ENABLE(WEB_TIMING)
475 m_performance->disconnectFrame();
480 m_location->disconnectFrame();
484 m_media->disconnectFrame();
487 #if ENABLE(DOM_STORAGE)
488 if (m_sessionStorage)
489 m_sessionStorage->disconnectFrame();
490 m_sessionStorage = 0;
493 m_localStorage->disconnectFrame();
497 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
498 if (m_applicationCache)
499 m_applicationCache->disconnectFrame();
500 m_applicationCache = 0;
503 #if ENABLE(NOTIFICATIONS)
505 m_notifications->disconnectFrame();
509 #if ENABLE(INDEXED_DATABASE)
514 #if ENABLE(ORIENTATION_EVENTS)
515 int DOMWindow::orientation() const
520 return m_frame->orientation();
524 Screen* DOMWindow::screen() const
527 m_screen = Screen::create(m_frame);
528 return m_screen.get();
531 History* DOMWindow::history() const
534 m_history = History::create(m_frame);
535 return m_history.get();
538 Crypto* DOMWindow::crypto() const
541 m_crypto = Crypto::create();
542 return m_crypto.get();
545 BarInfo* DOMWindow::locationbar() const
548 m_locationbar = BarInfo::create(m_frame, BarInfo::Locationbar);
549 return m_locationbar.get();
552 BarInfo* DOMWindow::menubar() const
555 m_menubar = BarInfo::create(m_frame, BarInfo::Menubar);
556 return m_menubar.get();
559 BarInfo* DOMWindow::personalbar() const
562 m_personalbar = BarInfo::create(m_frame, BarInfo::Personalbar);
563 return m_personalbar.get();
566 BarInfo* DOMWindow::scrollbars() const
569 m_scrollbars = BarInfo::create(m_frame, BarInfo::Scrollbars);
570 return m_scrollbars.get();
573 BarInfo* DOMWindow::statusbar() const
576 m_statusbar = BarInfo::create(m_frame, BarInfo::Statusbar);
577 return m_statusbar.get();
580 BarInfo* DOMWindow::toolbar() const
583 m_toolbar = BarInfo::create(m_frame, BarInfo::Toolbar);
584 return m_toolbar.get();
587 Console* DOMWindow::console() const
590 m_console = Console::create(m_frame);
591 return m_console.get();
594 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
595 DOMApplicationCache* DOMWindow::applicationCache() const
597 if (!m_applicationCache)
598 m_applicationCache = DOMApplicationCache::create(m_frame);
599 return m_applicationCache.get();
603 Navigator* DOMWindow::navigator() const
606 m_navigator = Navigator::create(m_frame);
607 return m_navigator.get();
610 #if ENABLE(WEB_TIMING)
611 Performance* DOMWindow::performance() const
614 m_performance = Performance::create(m_frame);
615 return m_performance.get();
619 Location* DOMWindow::location() const
622 m_location = Location::create(m_frame);
623 return m_location.get();
626 #if ENABLE(DOM_STORAGE)
627 Storage* DOMWindow::sessionStorage(ExceptionCode& ec) const
629 if (m_sessionStorage)
630 return m_sessionStorage.get();
632 Document* document = this->document();
636 if (!document->securityOrigin()->canAccessLocalStorage()) {
641 Page* page = document->page();
645 RefPtr<StorageArea> storageArea = page->sessionStorage()->storageArea(document->securityOrigin());
646 InspectorInstrumentation::didUseDOMStorage(page, storageArea.get(), false, m_frame);
648 m_sessionStorage = Storage::create(m_frame, storageArea.release());
649 return m_sessionStorage.get();
652 Storage* DOMWindow::localStorage(ExceptionCode& ec) const
655 return m_localStorage.get();
657 Document* document = this->document();
661 if (!document->securityOrigin()->canAccessLocalStorage()) {
666 Page* page = document->page();
670 if (!page->settings()->localStorageEnabled())
673 RefPtr<StorageArea> storageArea = page->group().localStorage()->storageArea(document->securityOrigin());
674 InspectorInstrumentation::didUseDOMStorage(page, storageArea.get(), true, m_frame);
676 m_localStorage = Storage::create(m_frame, storageArea.release());
677 return m_localStorage.get();
681 #if ENABLE(NOTIFICATIONS)
682 NotificationCenter* DOMWindow::webkitNotifications() const
685 return m_notifications.get();
687 Document* document = this->document();
691 Page* page = document->page();
695 NotificationPresenter* provider = page->chrome()->notificationPresenter();
697 m_notifications = NotificationCenter::create(document, provider);
699 return m_notifications.get();
703 void DOMWindow::pageDestroyed()
705 #if ENABLE(NOTIFICATIONS)
706 // Clearing Notifications requests involves accessing the client so it must be done
707 // before the frame is detached.
709 m_notifications->disconnectFrame();
714 #if ENABLE(INDEXED_DATABASE)
715 IDBFactory* DOMWindow::webkitIndexedDB() const
718 return m_idbFactory.get();
720 Document* document = this->document();
724 // FIXME: See if access is allowed.
726 Page* page = document->page();
730 // FIXME: See if indexedDatabase access is allowed.
732 m_idbFactory = IDBFactory::create(page->group().idbFactory());
733 return m_idbFactory.get();
737 #if ENABLE(FILE_SYSTEM)
738 void DOMWindow::requestFileSystem(int type, long long size, PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
740 Document* document = this->document();
744 if (!AsyncFileSystem::isAvailable() || !document->securityOrigin()->canAccessFileSystem()) {
745 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::SECURITY_ERR));
749 AsyncFileSystem::Type fileSystemType = static_cast<AsyncFileSystem::Type>(type);
750 if (fileSystemType != AsyncFileSystem::Temporary && fileSystemType != AsyncFileSystem::Persistent) {
751 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
755 LocalFileSystem::localFileSystem().requestFileSystem(document, fileSystemType, size, FileSystemCallbacks::create(successCallback, errorCallback, document), false);
758 void DOMWindow::resolveLocalFileSystemURI(const String& uri, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
760 Document* document = this->document();
764 SecurityOrigin* securityOrigin = document->securityOrigin();
765 KURL completedURL = document->completeURL(uri);
766 if (!AsyncFileSystem::isAvailable() || !securityOrigin->canAccessFileSystem() || !securityOrigin->canRequest(completedURL)) {
767 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::SECURITY_ERR));
771 AsyncFileSystem::Type type;
773 if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(completedURL, type, filePath)) {
774 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::SYNTAX_ERR));
778 LocalFileSystem::localFileSystem().readFileSystem(document, type, ResolveURICallbacks::create(successCallback, errorCallback, document, filePath));
781 COMPILE_ASSERT(static_cast<int>(DOMWindow::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch);
782 COMPILE_ASSERT(static_cast<int>(DOMWindow::PERSISTENT) == static_cast<int>(AsyncFileSystem::Persistent), enum_mismatch);
786 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort* port, const String& targetOrigin, DOMWindow* source, ExceptionCode& ec)
788 MessagePortArray ports;
791 postMessage(message, &ports, targetOrigin, source, ec);
794 void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, const String& targetOrigin, DOMWindow* source, ExceptionCode& ec)
799 // Compute the target origin. We need to do this synchronously in order
800 // to generate the SYNTAX_ERR exception correctly.
801 RefPtr<SecurityOrigin> target;
802 if (targetOrigin != "*") {
803 target = SecurityOrigin::createFromString(targetOrigin);
804 if (target->isEmpty()) {
810 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, ec);
814 // Capture the source of the message. We need to do this synchronously
815 // in order to capture the source of the message correctly.
816 Document* sourceDocument = source->document();
819 String sourceOrigin = sourceDocument->securityOrigin()->toString();
821 // Schedule the message.
822 PostMessageTimer* timer = new PostMessageTimer(this, message, sourceOrigin, source, channels.release(), target.get());
823 timer->startOneShot(0);
826 void DOMWindow::postMessageTimerFired(PostMessageTimer* t)
828 OwnPtr<PostMessageTimer> timer(t);
833 if (timer->targetOrigin()) {
834 // Check target origin now since the target document may have changed since the simer was scheduled.
835 if (!timer->targetOrigin()->isSameSchemeHostPort(document()->securityOrigin())) {
836 String message = makeString("Unable to post message to ", timer->targetOrigin()->toString(),
837 ". Recipient has origin ", document()->securityOrigin()->toString(), ".\n");
838 console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, 0, String());
843 dispatchEvent(timer->event(document()));
846 DOMSelection* DOMWindow::getSelection()
849 m_selection = DOMSelection::create(m_frame);
850 return m_selection.get();
853 Element* DOMWindow::frameElement() const
858 return m_frame->ownerElement();
861 void DOMWindow::focus()
866 Page* page = m_frame->page();
870 // If we're a top level window, bring the window to the front.
871 if (m_frame == page->mainFrame())
872 page->chrome()->focus();
877 m_frame->eventHandler()->focusDocumentView();
880 void DOMWindow::blur()
885 Page* page = m_frame->page();
889 if (m_frame != page->mainFrame())
892 page->chrome()->unfocus();
895 void DOMWindow::close(ScriptExecutionContext* context)
900 Page* page = m_frame->page();
904 if (m_frame != page->mainFrame())
908 ASSERT(WTF::isMainThread());
909 Frame* activeFrame = static_cast<Document*>(context)->frame();
913 if (!activeFrame->loader()->shouldAllowNavigation(m_frame))
917 Settings* settings = m_frame->settings();
918 bool allowScriptsToCloseWindows = settings && settings->allowScriptsToCloseWindows();
920 if (!(page->openedByDOM() || page->backForward()->count() <= 1 || allowScriptsToCloseWindows))
923 if (!m_frame->loader()->shouldClose())
926 page->chrome()->closeWindowSoon();
929 void DOMWindow::print()
934 Page* page = m_frame->page();
938 if (m_frame->loader()->activeDocumentLoader()->isLoading()) {
939 m_shouldPrintWhenFinishedLoading = true;
942 m_shouldPrintWhenFinishedLoading = false;
943 page->chrome()->print(m_frame);
946 void DOMWindow::stop()
951 // We must check whether the load is complete asynchronously, because we might still be parsing
952 // the document until the callstack unwinds.
953 m_frame->loader()->stopForUserCancel(true);
956 void DOMWindow::alert(const String& message)
961 m_frame->document()->updateStyleIfNeeded();
963 Page* page = m_frame->page();
967 page->chrome()->runJavaScriptAlert(m_frame, message);
970 bool DOMWindow::confirm(const String& message)
975 m_frame->document()->updateStyleIfNeeded();
977 Page* page = m_frame->page();
981 return page->chrome()->runJavaScriptConfirm(m_frame, message);
984 String DOMWindow::prompt(const String& message, const String& defaultValue)
989 m_frame->document()->updateStyleIfNeeded();
991 Page* page = m_frame->page();
996 if (page->chrome()->runJavaScriptPrompt(m_frame, message, defaultValue, returnValue))
1002 String DOMWindow::btoa(const String& stringToEncode, ExceptionCode& ec)
1004 if (stringToEncode.isNull())
1007 if (!stringToEncode.containsOnlyLatin1()) {
1008 ec = INVALID_CHARACTER_ERR;
1012 return base64Encode(stringToEncode.latin1());
1015 String DOMWindow::atob(const String& encodedString, ExceptionCode& ec)
1017 if (encodedString.isNull())
1020 if (!encodedString.containsOnlyLatin1()) {
1021 ec = INVALID_CHARACTER_ERR;
1026 if (!base64Decode(encodedString, out, FailOnInvalidCharacter)) {
1027 ec = INVALID_CHARACTER_ERR;
1031 return String(out.data(), out.size());
1034 bool DOMWindow::find(const String& string, bool caseSensitive, bool backwards, bool wrap, bool /*wholeWord*/, bool /*searchInFrames*/, bool /*showDialog*/) const
1039 // FIXME (13016): Support wholeWord, searchInFrames and showDialog
1040 return m_frame->editor()->findString(string, !backwards, caseSensitive, wrap, false);
1043 bool DOMWindow::offscreenBuffering() const
1048 int DOMWindow::outerHeight() const
1053 Page* page = m_frame->page();
1057 return static_cast<int>(page->chrome()->windowRect().height());
1060 int DOMWindow::outerWidth() const
1065 Page* page = m_frame->page();
1069 return static_cast<int>(page->chrome()->windowRect().width());
1072 int DOMWindow::innerHeight() const
1077 FrameView* view = m_frame->view();
1081 #if PLATFORM(ANDROID)
1082 return static_cast<int>(view->actualHeight() / m_frame->pageZoomFactor());
1084 return static_cast<int>(view->height() / m_frame->pageZoomFactor());
1088 int DOMWindow::innerWidth() const
1093 FrameView* view = m_frame->view();
1097 #if PLATFORM(ANDROID)
1098 return static_cast<int>(view->actualWidth() / m_frame->pageZoomFactor());
1100 return static_cast<int>(view->width() / m_frame->pageZoomFactor());
1104 int DOMWindow::screenX() const
1109 Page* page = m_frame->page();
1113 return static_cast<int>(page->chrome()->windowRect().x());
1116 int DOMWindow::screenY() const
1121 Page* page = m_frame->page();
1125 return static_cast<int>(page->chrome()->windowRect().y());
1128 int DOMWindow::scrollX() const
1133 FrameView* view = m_frame->view();
1137 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1139 #if PLATFORM(ANDROID)
1140 return static_cast<int>(view->actualScrollX() / m_frame->pageZoomFactor());
1142 return static_cast<int>(view->scrollX() / m_frame->pageZoomFactor());
1146 int DOMWindow::scrollY() const
1151 FrameView* view = m_frame->view();
1155 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1157 #if PLATFORM(ANDROID)
1158 return static_cast<int>(view->actualScrollY() / m_frame->pageZoomFactor());
1160 return static_cast<int>(view->scrollY() / m_frame->pageZoomFactor());
1164 bool DOMWindow::closed() const
1169 unsigned DOMWindow::length() const
1174 return m_frame->tree()->childCount();
1177 String DOMWindow::name() const
1182 return m_frame->tree()->name();
1185 void DOMWindow::setName(const String& string)
1190 m_frame->tree()->setName(string);
1193 void DOMWindow::setStatus(const String& string)
1200 Page* page = m_frame->page();
1204 ASSERT(m_frame->document()); // Client calls shouldn't be made when the frame is in inconsistent state.
1205 page->chrome()->setStatusbarText(m_frame, m_status);
1208 void DOMWindow::setDefaultStatus(const String& string)
1210 m_defaultStatus = string;
1215 Page* page = m_frame->page();
1219 ASSERT(m_frame->document()); // Client calls shouldn't be made when the frame is in inconsistent state.
1220 page->chrome()->setStatusbarText(m_frame, m_defaultStatus);
1223 DOMWindow* DOMWindow::self() const
1228 return m_frame->domWindow();
1231 DOMWindow* DOMWindow::opener() const
1236 Frame* opener = m_frame->loader()->opener();
1240 return opener->domWindow();
1243 DOMWindow* DOMWindow::parent() const
1248 Frame* parent = m_frame->tree()->parent(true);
1250 return parent->domWindow();
1252 return m_frame->domWindow();
1255 DOMWindow* DOMWindow::top() const
1260 Page* page = m_frame->page();
1264 return m_frame->tree()->top(true)->domWindow();
1267 Document* DOMWindow::document() const
1269 // FIXME: This function shouldn't need a frame to work.
1273 // The m_frame pointer is not zeroed out when the window is put into b/f cache, so it can hold an unrelated document/window pair.
1274 // FIXME: We should always zero out the frame pointer on navigation to avoid accidentally accessing the new frame content.
1275 if (m_frame->domWindow() != this)
1278 ASSERT(m_frame->document());
1279 return m_frame->document();
1282 PassRefPtr<StyleMedia> DOMWindow::styleMedia() const
1285 m_media = StyleMedia::create(m_frame);
1286 return m_media.get();
1289 PassRefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element* elt, const String& pseudoElt) const
1294 return computedStyle(elt, false, pseudoElt);
1297 PassRefPtr<CSSRuleList> DOMWindow::getMatchedCSSRules(Element* elt, const String&, bool authorOnly) const
1302 Settings* settings = m_frame->settings();
1303 return m_frame->document()->styleSelector()->styleRulesForElement(elt, authorOnly, false, settings && settings->crossOriginCheckInGetMatchedCSSRulesDisabled() ? AllCSSRules : SameOriginCSSRulesOnly);
1306 PassRefPtr<WebKitPoint> DOMWindow::webkitConvertPointFromNodeToPage(Node* node, const WebKitPoint* p) const
1311 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1313 FloatPoint pagePoint(p->x(), p->y());
1314 pagePoint = node->convertToPage(pagePoint);
1315 return WebKitPoint::create(pagePoint.x(), pagePoint.y());
1318 PassRefPtr<WebKitPoint> DOMWindow::webkitConvertPointFromPageToNode(Node* node, const WebKitPoint* p) const
1323 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1325 FloatPoint nodePoint(p->x(), p->y());
1326 nodePoint = node->convertFromPage(nodePoint);
1327 return WebKitPoint::create(nodePoint.x(), nodePoint.y());
1330 double DOMWindow::devicePixelRatio() const
1335 Page* page = m_frame->page();
1339 return page->chrome()->scaleFactor();
1342 #if ENABLE(DATABASE)
1343 PassRefPtr<Database> DOMWindow::openDatabase(const String& name, const String& version, const String& displayName, unsigned long estimatedSize, PassRefPtr<DatabaseCallback> creationCallback, ExceptionCode& ec)
1345 RefPtr<Database> database = 0;
1346 if (m_frame && AbstractDatabase::isAvailable() && m_frame->document()->securityOrigin()->canAccessDatabase())
1347 database = Database::openDatabase(m_frame->document(), name, version, displayName, estimatedSize, creationCallback, ec);
1349 if (!database && !ec)
1356 void DOMWindow::scrollBy(int x, int y) const
1361 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1363 RefPtr<FrameView> view = m_frame->view();
1367 view->scrollBy(IntSize(x, y));
1370 void DOMWindow::scrollTo(int x, int y) const
1375 m_frame->document()->updateLayoutIgnorePendingStylesheets();
1377 RefPtr<FrameView> view = m_frame->view();
1381 int zoomedX = static_cast<int>(x * m_frame->pageZoomFactor());
1382 int zoomedY = static_cast<int>(y * m_frame->pageZoomFactor());
1383 view->setScrollPosition(IntPoint(zoomedX, zoomedY));
1386 void DOMWindow::moveBy(float x, float y) const
1391 Page* page = m_frame->page();
1395 if (m_frame != page->mainFrame())
1398 FloatRect fr = page->chrome()->windowRect();
1399 FloatRect update = fr;
1401 // Security check (the spec talks about UniversalBrowserWrite to disable this check...)
1402 adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
1403 page->chrome()->setWindowRect(fr);
1406 void DOMWindow::moveTo(float x, float y) const
1411 Page* page = m_frame->page();
1415 if (m_frame != page->mainFrame())
1418 FloatRect fr = page->chrome()->windowRect();
1419 FloatRect sr = screenAvailableRect(page->mainFrame()->view());
1420 fr.setLocation(sr.location());
1421 FloatRect update = fr;
1423 // Security check (the spec talks about UniversalBrowserWrite to disable this check...)
1424 adjustWindowRect(sr, fr, update);
1425 page->chrome()->setWindowRect(fr);
1428 void DOMWindow::resizeBy(float x, float y) const
1433 Page* page = m_frame->page();
1437 if (m_frame != page->mainFrame())
1440 FloatRect fr = page->chrome()->windowRect();
1441 FloatSize dest = fr.size() + FloatSize(x, y);
1442 FloatRect update(fr.location(), dest);
1443 adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
1444 page->chrome()->setWindowRect(fr);
1447 void DOMWindow::resizeTo(float width, float height) const
1452 Page* page = m_frame->page();
1456 if (m_frame != page->mainFrame())
1459 FloatRect fr = page->chrome()->windowRect();
1460 FloatSize dest = FloatSize(width, height);
1461 FloatRect update(fr.location(), dest);
1462 adjustWindowRect(screenAvailableRect(page->mainFrame()->view()), fr, update);
1463 page->chrome()->setWindowRect(fr);
1466 int DOMWindow::setTimeout(PassOwnPtr<ScheduledAction> action, int timeout, ExceptionCode& ec)
1468 ScriptExecutionContext* context = scriptExecutionContext();
1470 ec = INVALID_ACCESS_ERR;
1473 return DOMTimer::install(context, action, timeout, true);
1476 void DOMWindow::clearTimeout(int timeoutId)
1478 ScriptExecutionContext* context = scriptExecutionContext();
1481 DOMTimer::removeById(context, timeoutId);
1484 int DOMWindow::setInterval(PassOwnPtr<ScheduledAction> action, int timeout, ExceptionCode& ec)
1486 ScriptExecutionContext* context = scriptExecutionContext();
1488 ec = INVALID_ACCESS_ERR;
1491 return DOMTimer::install(context, action, timeout, false);
1494 void DOMWindow::clearInterval(int timeoutId)
1496 ScriptExecutionContext* context = scriptExecutionContext();
1499 DOMTimer::removeById(context, timeoutId);
1502 #if ENABLE(REQUEST_ANIMATION_FRAME)
1503 int DOMWindow::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback, Element* e)
1505 if (Document* d = document())
1506 return d->webkitRequestAnimationFrame(callback, e);
1510 void DOMWindow::webkitCancelRequestAnimationFrame(int id)
1512 if (Document* d = document())
1513 d->webkitCancelRequestAnimationFrame(id);
1517 bool DOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture)
1519 if (!EventTarget::addEventListener(eventType, listener, useCapture))
1522 if (Document* document = this->document())
1523 document->addListenerTypeIfNeeded(eventType);
1525 if (eventType == eventNames().unloadEvent)
1526 addUnloadEventListener(this);
1527 else if (eventType == eventNames().beforeunloadEvent && allowsBeforeUnloadListeners(this))
1528 addBeforeUnloadEventListener(this);
1529 #if ENABLE(DEVICE_ORIENTATION)
1530 else if (eventType == eventNames().devicemotionEvent && frame() && frame()->page() && frame()->page()->deviceMotionController())
1531 frame()->page()->deviceMotionController()->addListener(this);
1532 else if (eventType == eventNames().deviceorientationEvent && frame() && frame()->page() && frame()->page()->deviceOrientationController())
1533 frame()->page()->deviceOrientationController()->addListener(this);
1539 bool DOMWindow::removeEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture)
1541 if (!EventTarget::removeEventListener(eventType, listener, useCapture))
1544 if (eventType == eventNames().unloadEvent)
1545 removeUnloadEventListener(this);
1546 else if (eventType == eventNames().beforeunloadEvent && allowsBeforeUnloadListeners(this))
1547 removeBeforeUnloadEventListener(this);
1548 #if ENABLE(DEVICE_ORIENTATION)
1549 else if (eventType == eventNames().devicemotionEvent && frame() && frame()->page() && frame()->page()->deviceMotionController())
1550 frame()->page()->deviceMotionController()->removeListener(this);
1551 else if (eventType == eventNames().deviceorientationEvent && frame() && frame()->page() && frame()->page()->deviceOrientationController())
1552 frame()->page()->deviceOrientationController()->removeListener(this);
1558 void DOMWindow::dispatchLoadEvent()
1560 RefPtr<Event> loadEvent(Event::create(eventNames().loadEvent, false, false));
1561 if (m_frame && m_frame->loader()->documentLoader() && !m_frame->loader()->documentLoader()->timing()->loadEventStart) {
1562 // The DocumentLoader (and thus its DocumentLoadTiming) might get destroyed while dispatching
1563 // the event, so protect it to prevent writing the end time into freed memory.
1564 RefPtr<DocumentLoader> documentLoader = m_frame->loader()->documentLoader();
1565 DocumentLoadTiming* timing = documentLoader->timing();
1566 dispatchTimedEvent(loadEvent, document(), &timing->loadEventStart, &timing->loadEventEnd);
1568 dispatchEvent(loadEvent, document());
1570 // For load events, send a separate load event to the enclosing frame only.
1571 // This is a DOM extension and is independent of bubbling/capturing rules of
1573 Element* ownerElement = m_frame ? m_frame->ownerElement() : 0;
1575 RefPtr<Event> ownerEvent = Event::create(eventNames().loadEvent, false, false);
1576 ownerEvent->setTarget(ownerElement);
1577 ownerElement->dispatchGenericEvent(ownerEvent.release());
1580 InspectorInstrumentation::loadEventFired(frame(), url());
1583 bool DOMWindow::dispatchEvent(PassRefPtr<Event> prpEvent, PassRefPtr<EventTarget> prpTarget)
1585 RefPtr<EventTarget> protect = this;
1586 RefPtr<Event> event = prpEvent;
1588 event->setTarget(prpTarget ? prpTarget : this);
1589 event->setCurrentTarget(this);
1590 event->setEventPhase(Event::AT_TARGET);
1592 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEventOnWindow(frame(), *event, this);
1594 bool result = fireEventListeners(event.get());
1596 InspectorInstrumentation::didDispatchEventOnWindow(cookie);
1601 void DOMWindow::dispatchTimedEvent(PassRefPtr<Event> event, Document* target, double* startTime, double* endTime)
1605 *startTime = currentTime();
1606 dispatchEvent(event, target);
1607 *endTime = currentTime();
1610 void DOMWindow::removeAllEventListeners()
1612 EventTarget::removeAllEventListeners();
1614 #if ENABLE(DEVICE_ORIENTATION)
1615 if (frame() && frame()->page() && frame()->page()->deviceMotionController())
1616 frame()->page()->deviceMotionController()->removeAllListeners(this);
1617 if (frame() && frame()->page() && frame()->page()->deviceOrientationController())
1618 frame()->page()->deviceOrientationController()->removeAllListeners(this);
1621 removeAllUnloadEventListeners(this);
1622 removeAllBeforeUnloadEventListeners(this);
1625 void DOMWindow::captureEvents()
1630 void DOMWindow::releaseEvents()
1635 void DOMWindow::finishedLoading()
1637 if (m_shouldPrintWhenFinishedLoading) {
1638 m_shouldPrintWhenFinishedLoading = false;
1643 EventTargetData* DOMWindow::eventTargetData()
1645 return &m_eventTargetData;
1648 EventTargetData* DOMWindow::ensureEventTargetData()
1650 return &m_eventTargetData;
1653 #if ENABLE(DOM_STORAGE) && defined(ANDROID)
1654 void DOMWindow::clearDOMStorage()
1656 if (m_sessionStorage)
1657 m_sessionStorage->disconnectFrame();
1658 m_sessionStorage = 0;
1661 m_localStorage->disconnectFrame();
1666 void DOMWindow::setLocation(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow, SetLocationLocking locking)
1671 Frame* activeFrame = activeWindow->frame();
1675 if (!activeFrame->loader()->shouldAllowNavigation(m_frame))
1678 Frame* firstFrame = firstWindow->frame();
1682 KURL completedURL = firstFrame->document()->completeURL(urlString);
1683 if (completedURL.isNull())
1686 if (isInsecureScriptAccess(activeWindow, urlString))
1689 // We want a new history item if we are processing a user gesture.
1690 m_frame->navigationScheduler()->scheduleLocationChange(activeFrame->document()->securityOrigin(),
1691 completedURL, activeFrame->loader()->outgoingReferrer(),
1692 locking != LockHistoryBasedOnGestureState || !activeFrame->script()->anyPageIsProcessingUserGesture(),
1693 locking != LockHistoryBasedOnGestureState);
1696 void DOMWindow::printErrorMessage(const String& message)
1698 if (message.isEmpty())
1701 Settings* settings = m_frame->settings();
1704 if (settings->privateBrowsingEnabled())
1707 // FIXME: Add arguments so that we can provide a correct source URL and line number.
1708 console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, 1, String());
1711 String DOMWindow::crossDomainAccessErrorMessage(DOMWindow* activeWindow)
1713 const KURL& activeWindowURL = activeWindow->url();
1714 if (activeWindowURL.isNull())
1717 // FIXME: This error message should contain more specifics of why the same origin check has failed.
1718 // Perhaps we should involve the security origin object in composing it.
1719 // FIXME: This message, and other console messages, have extra newlines. Should remove them.
1720 return makeString("Unsafe JavaScript attempt to access frame with URL ", m_url.string(),
1721 " from frame with URL ", activeWindowURL.string(), ". Domains, protocols and ports must match.\n");
1724 bool DOMWindow::isInsecureScriptAccess(DOMWindow* activeWindow, const String& urlString)
1726 if (!protocolIsJavaScript(urlString))
1729 // FIXME: Is there some way to eliminate the need for a separate "activeWindow == this" check?
1730 if (activeWindow == this)
1733 // FIXME: The name canAccess seems to be a roundabout way to ask "can execute script".
1734 // Can we name the SecurityOrigin function better to make this more clear?
1735 if (activeWindow->securityOrigin()->canAccess(securityOrigin()))
1738 printErrorMessage(crossDomainAccessErrorMessage(activeWindow));
1742 Frame* DOMWindow::createWindow(const String& urlString, const AtomicString& frameName, const WindowFeatures& windowFeatures,
1743 DOMWindow* activeWindow, Frame* firstFrame, Frame* openerFrame, PrepareDialogFunction function, void* functionContext)
1745 Frame* activeFrame = activeWindow->frame();
1747 // For whatever reason, Firefox uses the first frame to determine the outgoingReferrer. We replicate that behavior here.
1748 String referrer = firstFrame->loader()->outgoingReferrer();
1750 KURL completedURL = urlString.isEmpty() ? KURL(ParsedURLString, "") : firstFrame->document()->completeURL(urlString);
1751 ResourceRequest request(completedURL, referrer);
1752 FrameLoader::addHTTPOriginIfNeeded(request, firstFrame->loader()->outgoingOrigin());
1753 FrameLoadRequest frameRequest(activeWindow->securityOrigin(), request, frameName);
1755 // We pass the opener frame for the lookupFrame in case the active frame is different from
1756 // the opener frame, and the name references a frame relative to the opener frame.
1758 Frame* newFrame = WebCore::createWindow(activeFrame, openerFrame, frameRequest, windowFeatures, created);
1762 newFrame->loader()->setOpener(openerFrame);
1763 newFrame->page()->setOpenedByDOM();
1765 if (newFrame->domWindow()->isInsecureScriptAccess(activeWindow, urlString))
1769 function(newFrame->domWindow(), functionContext);
1772 newFrame->loader()->changeLocation(activeWindow->securityOrigin(), completedURL, referrer, false, false);
1773 else if (!urlString.isEmpty()) {
1774 newFrame->navigationScheduler()->scheduleLocationChange(activeWindow->securityOrigin(), completedURL.string(), referrer,
1775 !activeFrame->script()->anyPageIsProcessingUserGesture(), false);
1781 PassRefPtr<DOMWindow> DOMWindow::open(const String& urlString, const AtomicString& frameName, const String& windowFeaturesString,
1782 DOMWindow* activeWindow, DOMWindow* firstWindow)
1786 Frame* activeFrame = activeWindow->frame();
1789 Frame* firstFrame = firstWindow->frame();
1793 if (!firstWindow->allowPopUp()) {
1794 // Because FrameTree::find() returns true for empty strings, we must check for empty frame names.
1795 // Otherwise, illegitimate window.open() calls with no name will pass right through the popup blocker.
1796 if (frameName.isEmpty() || !m_frame->tree()->find(frameName))
1800 // Get the target frame for the special cases of _top and _parent.
1801 // In those cases, we schedule a location change right now and return early.
1802 Frame* targetFrame = 0;
1803 if (frameName == "_top")
1804 targetFrame = m_frame->tree()->top();
1805 else if (frameName == "_parent") {
1806 if (Frame* parent = m_frame->tree()->parent())
1807 targetFrame = parent;
1809 targetFrame = m_frame;
1812 if (!activeFrame->loader()->shouldAllowNavigation(targetFrame))
1815 if (isInsecureScriptAccess(activeWindow, urlString))
1816 return targetFrame->domWindow();
1818 if (urlString.isEmpty())
1819 return targetFrame->domWindow();
1821 // For whatever reason, Firefox uses the first window rather than the active window to
1822 // determine the outgoing referrer. We replicate that behavior here.
1823 targetFrame->navigationScheduler()->scheduleLocationChange(activeFrame->document()->securityOrigin(),
1824 firstFrame->document()->completeURL(urlString).string(),
1825 firstFrame->loader()->outgoingReferrer(),
1826 !activeFrame->script()->anyPageIsProcessingUserGesture(), false);
1828 return targetFrame->domWindow();
1831 WindowFeatures windowFeatures(windowFeaturesString);
1832 FloatRect windowRect(windowFeatures.xSet ? windowFeatures.x : 0, windowFeatures.ySet ? windowFeatures.y : 0,
1833 windowFeatures.widthSet ? windowFeatures.width : 0, windowFeatures.heightSet ? windowFeatures.height : 0);
1834 Page* page = m_frame->page();
1835 DOMWindow::adjustWindowRect(screenAvailableRect(page ? page->mainFrame()->view() : 0), windowRect, windowRect);
1836 windowFeatures.x = windowRect.x();
1837 windowFeatures.y = windowRect.y();
1838 windowFeatures.height = windowRect.height();
1839 windowFeatures.width = windowRect.width();
1841 Frame* result = createWindow(urlString, frameName, windowFeatures, activeWindow, firstFrame, m_frame);
1842 return result ? result->domWindow() : 0;
1845 void DOMWindow::showModalDialog(const String& urlString, const String& dialogFeaturesString,
1846 DOMWindow* activeWindow, DOMWindow* firstWindow, PrepareDialogFunction function, void* functionContext)
1850 Frame* activeFrame = activeWindow->frame();
1853 Frame* firstFrame = firstWindow->frame();
1857 if (!canShowModalDialogNow(m_frame) || !firstWindow->allowPopUp())
1860 Frame* dialogFrame = createWindow(urlString, emptyAtom, WindowFeatures(dialogFeaturesString, screenAvailableRect(m_frame->view())),
1861 activeWindow, firstFrame, m_frame, function, functionContext);
1865 dialogFrame->page()->chrome()->runModal();
1869 DOMURL* DOMWindow::webkitURL() const
1872 m_domURL = DOMURL::create(this->scriptExecutionContext());
1873 return m_domURL.get();
1877 } // namespace WebCore