| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 if (!(frame() && frame()->owner() && frame()->owner()->isLocal())) | 728 if (!(frame() && frame()->owner() && frame()->owner()->isLocal())) |
| 729 return nullptr; | 729 return nullptr; |
| 730 | 730 |
| 731 return toHTMLFrameOwnerElement(frame()->owner()); | 731 return toHTMLFrameOwnerElement(frame()->owner()); |
| 732 } | 732 } |
| 733 | 733 |
| 734 void LocalDOMWindow::blur() | 734 void LocalDOMWindow::blur() |
| 735 { | 735 { |
| 736 } | 736 } |
| 737 | 737 |
| 738 void LocalDOMWindow::print() | 738 void LocalDOMWindow::print(ScriptState* scriptState) |
| 739 { | 739 { |
| 740 if (!frame()) | 740 if (!frame()) |
| 741 return; | 741 return; |
| 742 | 742 |
| 743 FrameHost* host = frame()->host(); | 743 FrameHost* host = frame()->host(); |
| 744 if (!host) | 744 if (!host) |
| 745 return; | 745 return; |
| 746 | 746 |
| 747 if (frame()->document()->isSandboxed(SandboxModals)) { | 747 if (frame()->document()->isSandboxed(SandboxModals)) { |
| 748 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); | 748 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); |
| 749 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { | 749 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { |
| 750 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'print()'. The document is sandboxed, a
nd the 'allow-modals' keyword is not set.")); | 750 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'print()'. The document is sandboxed, a
nd the 'allow-modals' keyword is not set.")); |
| 751 return; | 751 return; |
| 752 } | 752 } |
| 753 } | 753 } |
| 754 | 754 |
| 755 if (scriptState && v8::MicrotasksScope::IsRunningMicrotasks(scriptState->iso
late())) { |
| 756 Deprecation::countDeprecation(frame()->document(), UseCounter::During_Mi
crotask_Print); |
| 757 if (RuntimeEnabledFeatures::disableBlockingMethodsDuringMicrotasksEnable
d()) { |
| 758 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'print()' during microtask execution.")
); |
| 759 return; |
| 760 } |
| 761 } |
| 762 |
| 755 if (frame()->isLoading()) { | 763 if (frame()->isLoading()) { |
| 756 m_shouldPrintWhenFinishedLoading = true; | 764 m_shouldPrintWhenFinishedLoading = true; |
| 757 return; | 765 return; |
| 758 } | 766 } |
| 759 m_shouldPrintWhenFinishedLoading = false; | 767 m_shouldPrintWhenFinishedLoading = false; |
| 760 host->chromeClient().print(frame()); | 768 host->chromeClient().print(frame()); |
| 761 } | 769 } |
| 762 | 770 |
| 763 void LocalDOMWindow::stop() | 771 void LocalDOMWindow::stop() |
| 764 { | 772 { |
| 765 if (!frame()) | 773 if (!frame()) |
| 766 return; | 774 return; |
| 767 frame()->loader().stopAllLoaders(); | 775 frame()->loader().stopAllLoaders(); |
| 768 } | 776 } |
| 769 | 777 |
| 770 void LocalDOMWindow::alert(const String& message) | 778 void LocalDOMWindow::alert(ScriptState* scriptState, const String& message) |
| 771 { | 779 { |
| 772 if (!frame()) | 780 if (!frame()) |
| 773 return; | 781 return; |
| 774 | 782 |
| 775 if (frame()->document()->isSandboxed(SandboxModals)) { | 783 if (frame()->document()->isSandboxed(SandboxModals)) { |
| 776 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); | 784 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); |
| 777 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { | 785 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { |
| 778 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'alert()'. The document is sandboxed, a
nd the 'allow-modals' keyword is not set.")); | 786 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'alert()'. The document is sandboxed, a
nd the 'allow-modals' keyword is not set.")); |
| 779 return; | 787 return; |
| 780 } | 788 } |
| 781 } | 789 } |
| 782 | 790 |
| 791 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { |
| 792 Deprecation::countDeprecation(frame()->document(), UseCounter::During_Mi
crotask_Alert); |
| 793 if (RuntimeEnabledFeatures::disableBlockingMethodsDuringMicrotasksEnable
d()) { |
| 794 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'alert()' during microtask execution.")
); |
| 795 return; |
| 796 } |
| 797 } |
| 798 |
| 783 frame()->document()->updateLayoutTree(); | 799 frame()->document()->updateLayoutTree(); |
| 784 | 800 |
| 785 FrameHost* host = frame()->host(); | 801 FrameHost* host = frame()->host(); |
| 786 if (!host) | 802 if (!host) |
| 787 return; | 803 return; |
| 788 | 804 |
| 789 host->chromeClient().openJavaScriptAlert(frame(), message); | 805 host->chromeClient().openJavaScriptAlert(frame(), message); |
| 790 } | 806 } |
| 791 | 807 |
| 792 bool LocalDOMWindow::confirm(const String& message) | 808 bool LocalDOMWindow::confirm(ScriptState* scriptState, const String& message) |
| 793 { | 809 { |
| 794 if (!frame()) | 810 if (!frame()) |
| 795 return false; | 811 return false; |
| 796 | 812 |
| 797 if (frame()->document()->isSandboxed(SandboxModals)) { | 813 if (frame()->document()->isSandboxed(SandboxModals)) { |
| 798 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); | 814 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); |
| 799 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { | 815 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { |
| 800 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'confirm()'. The document is sandboxed,
and the 'allow-modals' keyword is not set.")); | 816 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'confirm()'. The document is sandboxed,
and the 'allow-modals' keyword is not set.")); |
| 801 return false; | 817 return false; |
| 802 } | 818 } |
| 803 } | 819 } |
| 804 | 820 |
| 821 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { |
| 822 Deprecation::countDeprecation(frame()->document(), UseCounter::During_Mi
crotask_Confirm); |
| 823 if (RuntimeEnabledFeatures::disableBlockingMethodsDuringMicrotasksEnable
d()) { |
| 824 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'confirm()' during microtask execution.
")); |
| 825 return false; |
| 826 } |
| 827 } |
| 828 |
| 805 frame()->document()->updateLayoutTree(); | 829 frame()->document()->updateLayoutTree(); |
| 806 | 830 |
| 807 FrameHost* host = frame()->host(); | 831 FrameHost* host = frame()->host(); |
| 808 if (!host) | 832 if (!host) |
| 809 return false; | 833 return false; |
| 810 | 834 |
| 811 return host->chromeClient().openJavaScriptConfirm(frame(), message); | 835 return host->chromeClient().openJavaScriptConfirm(frame(), message); |
| 812 } | 836 } |
| 813 | 837 |
| 814 String LocalDOMWindow::prompt(const String& message, const String& defaultValue) | 838 String LocalDOMWindow::prompt(ScriptState* scriptState, const String& message, c
onst String& defaultValue) |
| 815 { | 839 { |
| 816 if (!frame()) | 840 if (!frame()) |
| 817 return String(); | 841 return String(); |
| 818 | 842 |
| 819 if (frame()->document()->isSandboxed(SandboxModals)) { | 843 if (frame()->document()->isSandboxed(SandboxModals)) { |
| 820 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); | 844 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); |
| 821 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { | 845 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { |
| 822 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'prompt()'. The document is sandboxed,
and the 'allow-modals' keyword is not set.")); | 846 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'prompt()'. The document is sandboxed,
and the 'allow-modals' keyword is not set.")); |
| 823 return String(); | 847 return String(); |
| 824 } | 848 } |
| 825 } | 849 } |
| 826 | 850 |
| 851 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { |
| 852 Deprecation::countDeprecation(frame()->document(), UseCounter::During_Mi
crotask_Prompt); |
| 853 if (RuntimeEnabledFeatures::disableBlockingMethodsDuringMicrotasksEnable
d()) { |
| 854 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'prompt()' during microtask execution."
)); |
| 855 return String(); |
| 856 } |
| 857 } |
| 858 |
| 827 frame()->document()->updateLayoutTree(); | 859 frame()->document()->updateLayoutTree(); |
| 828 | 860 |
| 829 FrameHost* host = frame()->host(); | 861 FrameHost* host = frame()->host(); |
| 830 if (!host) | 862 if (!host) |
| 831 return String(); | 863 return String(); |
| 832 | 864 |
| 833 String returnValue; | 865 String returnValue; |
| 834 if (host->chromeClient().openJavaScriptPrompt(frame(), message, defaultValue
, returnValue)) | 866 if (host->chromeClient().openJavaScriptPrompt(frame(), message, defaultValue
, returnValue)) |
| 835 return returnValue; | 867 return returnValue; |
| 836 | 868 |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 frame()->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this)
; | 1429 frame()->host()->eventHandlerRegistry().didRemoveAllEventHandlers(*this)
; |
| 1398 | 1430 |
| 1399 removeAllUnloadEventListeners(this); | 1431 removeAllUnloadEventListeners(this); |
| 1400 removeAllBeforeUnloadEventListeners(this); | 1432 removeAllBeforeUnloadEventListeners(this); |
| 1401 } | 1433 } |
| 1402 | 1434 |
| 1403 void LocalDOMWindow::finishedLoading() | 1435 void LocalDOMWindow::finishedLoading() |
| 1404 { | 1436 { |
| 1405 if (m_shouldPrintWhenFinishedLoading) { | 1437 if (m_shouldPrintWhenFinishedLoading) { |
| 1406 m_shouldPrintWhenFinishedLoading = false; | 1438 m_shouldPrintWhenFinishedLoading = false; |
| 1407 print(); | 1439 print(nullptr); |
| 1408 } | 1440 } |
| 1409 } | 1441 } |
| 1410 | 1442 |
| 1411 void LocalDOMWindow::printErrorMessage(const String& message) const | 1443 void LocalDOMWindow::printErrorMessage(const String& message) const |
| 1412 { | 1444 { |
| 1413 if (!isCurrentlyDisplayedInFrame()) | 1445 if (!isCurrentlyDisplayedInFrame()) |
| 1414 return; | 1446 return; |
| 1415 | 1447 |
| 1416 if (message.isEmpty()) | 1448 if (message.isEmpty()) |
| 1417 return; | 1449 return; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1505 { | 1537 { |
| 1506 // If the LocalDOMWindow still has a frame reference, that frame must point | 1538 // If the LocalDOMWindow still has a frame reference, that frame must point |
| 1507 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation | 1539 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation |
| 1508 // where script execution leaks between different LocalDOMWindows. | 1540 // where script execution leaks between different LocalDOMWindows. |
| 1509 if (m_frameObserver->frame()) | 1541 if (m_frameObserver->frame()) |
| 1510 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); | 1542 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); |
| 1511 return m_frameObserver->frame(); | 1543 return m_frameObserver->frame(); |
| 1512 } | 1544 } |
| 1513 | 1545 |
| 1514 } // namespace blink | 1546 } // namespace blink |
| OLD | NEW |