Changeset 29051 in webkit


Ignore:
Timestamp:
Dec 31, 2007 4:18:16 PM (16 years ago)
Author:
Darin Adler
Message:

WebCore:

Reviewed by Darin.

Patch for http://bugs.webkit.org/show_bug.cgi?id=14994
Support for MessageEvent and cross-domain messaging

Test: http/tests/messaging/cross-domain-message-send.html

  • DerivedSources.make:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • WebCoreSources.bkl:
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::customGetOwnPropertySlot): Allow cross-domain access to the postMessage function. (WebCore::JSDOMWindow::postMessage):
  • bindings/js/JSEventCustom.cpp: (WebCore::toJS):
  • dom/Event.cpp: (WebCore::Event::isMessageEvent):
  • dom/Event.h:
  • dom/EventNames.h: New event name
  • dom/MessageEvent.cpp: Added.
  • dom/MessageEvent.h: Added.
  • dom/MessageEvent.idl: Added.
  • page/DOMWindow.cpp: (WebCore::DOMWindow::postMessage): Added.
  • page/DOMWindow.h:
  • page/DOMWindow.idl:

LayoutTests:

Reviewed by Darin.

Test for http://bugs.webkit.org/show_bug.cgi?id=14994
Support for MessageEvent and cross-domain messaging

  • fast/dom/Window/window-properties-expected.txt:
  • http/tests/messaging: Added.
  • http/tests/messaging/cross-domain-message-send-expected.txt: Added.
  • http/tests/messaging/cross-domain-message-send.html: Added.
  • http/tests/messaging/resources: Added.
  • http/tests/messaging/resources/cross-domain-message-receive.html: Added.
Location:
trunk
Files:
8 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r29044 r29051  
     12007-12-31  Henry Mason  <hmason@mac.com>
     2
     3        Reviewed by Darin.
     4
     5        Test for http://bugs.webkit.org/show_bug.cgi?id=14994
     6        Support for MessageEvent and cross-domain messaging
     7
     8        * fast/dom/Window/window-properties-expected.txt:
     9        * http/tests/messaging: Added.
     10        * http/tests/messaging/cross-domain-message-send-expected.txt: Added.
     11        * http/tests/messaging/cross-domain-message-send.html: Added.
     12        * http/tests/messaging/resources: Added.
     13        * http/tests/messaging/resources/cross-domain-message-receive.html: Added.
     14
    1152007-12-30  Sam Weinig  <sam@webkit.org>
    216
  • trunk/LayoutTests/fast/dom/Window/window-properties-expected.txt

    r29041 r29051  
    705705window.MediaList.prototype.deleteMedium [function]
    706706window.MediaList.prototype.item [function]
     707window.MessageEvent [object MessageEventConstructor]
     708window.MessageEvent.prototype [printed above as window.Event.prototype]
    707709window.MouseEvent [object MouseEventConstructor]
    708710window.MouseEvent.prototype [printed above as window.Event.prototype]
     
    12551257window.personalbar [object BarInfo]
    12561258window.personalbar.visible [boolean]
     1259window.postMessage [function]
    12571260window.print [function]
    12581261window.prompt [function]
  • trunk/WebCore/ChangeLog

    r29050 r29051  
     12007-12-31  Henry Mason  <hmason@mac.com>
     2
     3        Reviewed by Darin.
     4
     5        Patch for http://bugs.webkit.org/show_bug.cgi?id=14994
     6        Support for MessageEvent and cross-domain messaging
     7
     8        Test: http/tests/messaging/cross-domain-message-send.html
     9
     10        * DerivedSources.make:
     11        * WebCore.pro:
     12        * WebCore.vcproj/WebCore.vcproj:
     13        * WebCore.xcodeproj/project.pbxproj:
     14        * WebCoreSources.bkl:
     15        * bindings/js/JSDOMWindowCustom.cpp:
     16        (WebCore::JSDOMWindow::customGetOwnPropertySlot): Allow cross-domain access to the
     17        postMessage function.
     18        (WebCore::JSDOMWindow::postMessage):
     19        * bindings/js/JSEventCustom.cpp:
     20        (WebCore::toJS):
     21        * dom/Event.cpp:
     22        (WebCore::Event::isMessageEvent):
     23        * dom/Event.h:
     24        * dom/EventNames.h: New event name
     25        * dom/MessageEvent.cpp: Added.
     26        * dom/MessageEvent.h: Added.
     27        * dom/MessageEvent.idl: Added.
     28        * page/DOMWindow.cpp:
     29        (WebCore::DOMWindow::postMessage): Added.
     30        * page/DOMWindow.h:
     31        * page/DOMWindow.idl:
     32
    1332007-12-31  Darin Adler  <darin@apple.com>
    234
  • trunk/WebCore/DerivedSources.make

    r29012 r29051  
    134134    DOMHTMLUListElement.h \
    135135    DOMKeyboardEvent.h \
     136    DOMMessageEvent.h \
    136137    DOMMediaList.h \
    137138    DOMMouseEvent.h \
     
    416417    JSMediaError.h \
    417418    JSMediaList.h \
     419    JSMessageEvent.h \
    418420    JSMouseEvent.h \
    419421    JSMutationEvent.h \
  • trunk/WebCore/WebCore.pro

    r29012 r29051  
    282282#    dom/EventTarget.idl \
    283283    dom/KeyboardEvent.idl \
     284    dom/MessageEvent.idl \
    284285    dom/MouseEvent.idl \
    285286    dom/MutationEvent.idl \
     
    499500    dom/KeyboardEvent.cpp \
    500501    dom/MappedAttribute.cpp \
     502    dom/MessageEvent.cpp \
    501503    dom/MouseEvent.cpp \
    502504    dom/MouseRelatedEvent.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r29050 r29051  
    11771177                                >
    11781178                        </File>
     1179                        <File
     1180                                RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSMessageEvent.cpp"
     1181                                >
     1182                        </File>
     1183                        <File
     1184                                RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSMessageEvent.h"
     1185                                >
     1186                        </File>
    11791187                        <File
    11801188                                RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSMouseEvent.cpp"
     
    60536061                                >
    60546062                        </File>
     6063                        <File
     6064                                RelativePath="..\dom\MessageEvent.cpp"
     6065                                >
     6066                        </File>
     6067                        <File
     6068                                RelativePath="..\dom\MessageEvent.h"
     6069                                >
     6070                        </File>
    60556071                        <File
    60566072                                RelativePath="..\dom\MouseEvent.cpp"
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r29041 r29051  
    541541                65DF326109D1E199000BE325 /* UserAgentStyleSheetsData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 656581AF09D14EE6000E61D7 /* UserAgentStyleSheetsData.cpp */; };
    542542                65FEA86909833ADE00BED4AB /* Page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65FEA86809833ADE00BED4AB /* Page.cpp */; };
     543                75793E830D0CE0B3007FC0AC /* MessageEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75793E800D0CE0B3007FC0AC /* MessageEvent.cpp */; };
     544                75793E840D0CE0B3007FC0AC /* MessageEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 75793E810D0CE0B3007FC0AC /* MessageEvent.h */; };
     545                75793E850D0CE0B3007FC0AC /* MessageEvent.idl in Resources */ = {isa = PBXBuildFile; fileRef = 75793E820D0CE0B3007FC0AC /* MessageEvent.idl */; };
     546                75793EC80D0CE72D007FC0AC /* JSMessageEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75793EC60D0CE72D007FC0AC /* JSMessageEvent.cpp */; };
     547                75793EC90D0CE72D007FC0AC /* JSMessageEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 75793EC70D0CE72D007FC0AC /* JSMessageEvent.h */; };
     548                75793ED30D0CE85B007FC0AC /* DOMMessageEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 75793ED00D0CE85B007FC0AC /* DOMMessageEvent.h */; };
     549                75793ED40D0CE85B007FC0AC /* DOMMessageEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75793ED10D0CE85B007FC0AC /* DOMMessageEvent.mm */; };
     550                75793ED50D0CE85B007FC0AC /* DOMMessageEventInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 75793ED20D0CE85B007FC0AC /* DOMMessageEventInternal.h */; };
    543551                7E6FEED80898582300C44C3F /* WebCoreScriptDebugger.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E6FEED60898582300C44C3F /* WebCoreScriptDebugger.h */; settings = {ATTRIBUTES = (Private, ); }; };
    544552                7E6FEED90898582300C44C3F /* WebCoreScriptDebugger.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7E6FEED70898582300C44C3F /* WebCoreScriptDebugger.mm */; };
     
    49384946                65F80697054D9F86008BF776 /* BlockExceptions.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BlockExceptions.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    49394947                65FEA86809833ADE00BED4AB /* Page.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Page.cpp; sourceTree = "<group>"; };
     4948                75793E800D0CE0B3007FC0AC /* MessageEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = MessageEvent.cpp; path = dom/MessageEvent.cpp; sourceTree = SOURCE_ROOT; };
     4949                75793E810D0CE0B3007FC0AC /* MessageEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MessageEvent.h; path = dom/MessageEvent.h; sourceTree = SOURCE_ROOT; };
     4950                75793E820D0CE0B3007FC0AC /* MessageEvent.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = MessageEvent.idl; path = dom/MessageEvent.idl; sourceTree = SOURCE_ROOT; };
     4951                75793EC60D0CE72D007FC0AC /* JSMessageEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSMessageEvent.cpp; sourceTree = "<group>"; };
     4952                75793EC70D0CE72D007FC0AC /* JSMessageEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSMessageEvent.h; sourceTree = "<group>"; };
     4953                75793ED00D0CE85B007FC0AC /* DOMMessageEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMMessageEvent.h; sourceTree = "<group>"; };
     4954                75793ED10D0CE85B007FC0AC /* DOMMessageEvent.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMMessageEvent.mm; sourceTree = "<group>"; };
     4955                75793ED20D0CE85B007FC0AC /* DOMMessageEventInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMMessageEventInternal.h; sourceTree = "<group>"; };
    49404956                7E6FEED60898582300C44C3F /* WebCoreScriptDebugger.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreScriptDebugger.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    49414957                7E6FEED70898582300C44C3F /* WebCoreScriptDebugger.mm */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreScriptDebugger.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     
    92609276                                85FF31580AAFBFCB00374F38 /* DOMKeyboardEvent.h */,
    92619277                                85FF31590AAFBFCB00374F38 /* DOMKeyboardEvent.mm */,
     9278                                75793ED00D0CE85B007FC0AC /* DOMMessageEvent.h */,
     9279                                75793ED10D0CE85B007FC0AC /* DOMMessageEvent.mm */,
     9280                                75793ED20D0CE85B007FC0AC /* DOMMessageEventInternal.h */,
    92629281                                857E0B2B0AB043FC0036E447 /* DOMMouseEventPrivate.h */,
    92639282                                857E0B230AB043460036E447 /* DOMMouseEvent.h */,
     
    1061010629                                A86629CE09DA2B47009633A5 /* JSKeyboardEvent.cpp */,
    1061110630                                A86629CD09DA2B47009633A5 /* JSKeyboardEvent.h */,
     10631                                75793EC60D0CE72D007FC0AC /* JSMessageEvent.cpp */,
     10632                                75793EC70D0CE72D007FC0AC /* JSMessageEvent.h */,
    1061210633                                A86629CC09DA2B47009633A5 /* JSMouseEvent.cpp */,
    1061310634                                A86629CB09DA2B47009633A5 /* JSMouseEvent.h */,
     
    1230712328                                A8C4A7F309D563270003AC8D /* MappedAttribute.h */,
    1230812329                                A8C4A84B09D5649D0003AC8D /* MappedAttributeEntry.h */,
     12330                                75793E800D0CE0B3007FC0AC /* MessageEvent.cpp */,
     12331                                75793E810D0CE0B3007FC0AC /* MessageEvent.h */,
     12332                                75793E820D0CE0B3007FC0AC /* MessageEvent.idl */,
    1230912333                                85031B2F0A44EFC700F992E0 /* MouseEvent.cpp */,
    1231012334                                85031B300A44EFC700F992E0 /* MouseEvent.h */,
     
    1424614270                                BCA379150D163E5500B793D6 /* JSLocation.h in Headers */,
    1424714271                                BCA3793F0D1647E000B793D6 /* JSLocation.lut.h in Headers */,
     14272                                75793E840D0CE0B3007FC0AC /* MessageEvent.h in Headers */,
     14273                                75793EC90D0CE72D007FC0AC /* JSMessageEvent.h in Headers */,
     14274                                75793ED30D0CE85B007FC0AC /* DOMMessageEvent.h in Headers */,
     14275                                75793ED50D0CE85B007FC0AC /* DOMMessageEventInternal.h in Headers */,
    1424814276                                BC7FA6210D1F0CBD00DB22A9 /* DynamicNodeList.h in Headers */,
    1424914277                                BC7FA62D0D1F0EFF00DB22A9 /* StaticNodeList.h in Headers */,
     
    1447214500                                B255996B0D00D8BA00BB825C /* WKSpotLightFilter.cikernel in Resources */,
    1447314501                                B255996E0D00D8BA00BB825C /* WKTableTransferFilter.cikernel in Resources */,
     14502                                75793E850D0CE0B3007FC0AC /* MessageEvent.idl in Resources */,
    1447414503                                46F9D5DD0B0D60170028EE36 /* aliasCursor.png in Resources */,
    1447514504                                46D4F2490AF97E810035385A /* cellCursor.png in Resources */,
     
    1596815997                                93309E1D099E64920056E581 /* visible_units.cpp in Sources */,
    1596915998                                BCA379140D163E5500B793D6 /* JSLocation.cpp in Sources */,
     15999                                75793E830D0CE0B3007FC0AC /* MessageEvent.cpp in Sources */,
     16000                                75793EC80D0CE72D007FC0AC /* JSMessageEvent.cpp in Sources */,
     16001                                75793ED40D0CE85B007FC0AC /* DOMMessageEvent.mm in Sources */,
    1597016002                                B2A1F2AA0CEF0ABF00442F6A /* SVGFontElement.cpp in Sources */,
    1597116003                                B2A1F2AD0CEF0ABF00442F6A /* SVGGlyphElement.cpp in Sources */,
  • trunk/WebCore/WebCoreSources.bkl

    r28989 r29051  
    246246        DerivedSources/WebCore/JSKeyboardEvent.cpp
    247247        DerivedSources/WebCore/JSMediaList.cpp
     248        DerivedSources/WebCore/JSMessageEvent.cpp
    248249        DerivedSources/WebCore/JSMouseEvent.cpp
    249250        DerivedSources/WebCore/JSMutationEvent.cpp
     
    314315        dom/KeyboardEvent.cpp
    315316        dom/MappedAttribute.cpp
     317        dom/MessageEvent.cpp
    316318        dom/MouseEvent.cpp
    317319        dom/MouseRelatedEvent.cpp
  • trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r28884 r29051  
    2121#include "JSDOMWindow.h"
    2222
     23#include "Document.h"
     24#include "DOMWindow.h"
     25#include "ExceptionCode.h"
    2326#include "kjs_window.h"
    24 #include "DOMWindow.h"
     27#include "kjs/object.h"
     28#include "kjs/value.h"
    2529
    2630namespace WebCore {
     
    7175                if (entry->value.functionValue == &JSDOMWindowPrototypeFunctionFocus::create
    7276                    || entry->value.functionValue == &JSDOMWindowPrototypeFunctionBlur::create
    73                     || entry->value.functionValue == &JSDOMWindowPrototypeFunctionClose::create)
     77                    || entry->value.functionValue == &JSDOMWindowPrototypeFunctionClose::create
     78                    || entry->value.functionValue == &JSDOMWindowPrototypeFunctionPostMessage::create)
    7479                        slot.setStaticEntry(this, entry, KJS::staticFunctionGetter);
    7580                else {
     
    109114}
    110115
     116KJS::JSValue* JSDOMWindow::postMessage(KJS::ExecState* exec, const KJS::List& args)
     117{
     118    DOMWindow* window = impl();
     119   
     120    DOMWindow* source = static_cast<JSDOMWindow*>(exec->dynamicGlobalObject())->impl();
     121    String domain = source->document()->securityOrigin()->domain();
     122    String uri = source->document()->documentURI();
     123    String message = args[0]->toString(exec);
     124   
     125    if (exec->hadException())
     126        return KJS::jsUndefined();
     127   
     128    window->postMessage(message, domain, uri, source);
     129   
     130    return KJS::jsUndefined();
     131}
     132
    111133} // namespace WebCore
  • trunk/WebCore/bindings/js/JSEventCustom.cpp

    r28468 r29051  
    3333#include "Event.h"
    3434#include "JSKeyboardEvent.h"
     35#include "JSMessageEvent.h"
    3536#include "JSMouseEvent.h"
    3637#include "JSMutationEvent.h"
     
    4142#include "JSWheelEvent.h"
    4243#include "KeyboardEvent.h"
     44#include "MessageEvent.h"
    4345#include "MouseEvent.h"
    4446#include "MutationEvent.h"
     
    8587    else if (event->isOverflowEvent())
    8688        ret = new JSOverflowEvent(exec, static_cast<OverflowEvent*>(event));
     89    else if (event->isMessageEvent())
     90        ret = new JSMessageEvent(exec, static_cast<MessageEvent*>(event));
    8791    else if (event->isProgressEvent())
    8892        ret = new JSProgressEvent(exec, static_cast<ProgressEvent*>(event));
  • trunk/WebCore/dom/Event.cpp

    r27277 r29051  
    111111}
    112112
     113bool Event::isMessageEvent() const
     114{
     115    return false;
     116}
     117
    113118bool Event::isBeforeTextInsertedEvent() const
    114119{
  • trunk/WebCore/dom/Event.h

    r27776 r29051  
    107107        virtual bool isDragEvent() const; // a subset of mouse events
    108108        virtual bool isClipboardEvent() const;
     109        virtual bool isMessageEvent() const;
    109110        virtual bool isWheelEvent() const;
    110111        virtual bool isBeforeTextInsertedEvent() const;
  • trunk/WebCore/dom/EventNames.h

    r27277 r29051  
    5555    macro(keyup) \
    5656    macro(load) \
     57    macro(message) \
    5758    macro(mousedown) \
    5859    macro(mousemove) \
  • trunk/WebCore/page/DOMWindow.cpp

    r29033 r29051  
    4242#include "FrameView.h"
    4343#include "History.h"
     44#include "MessageEvent.h"
    4445#include "Page.h"
    4546#include "PlatformScreen.h"
     
    220221}
    221222
     223void DOMWindow::postMessage(const String& message, const String& domain, const String& uri, DOMWindow* source) const
     224{
     225   ExceptionCode ec;
     226   document()->dispatchEvent(new MessageEvent(message, domain, uri, source), ec, true);
     227}
     228
    222229DOMSelection* DOMWindow::getSelection()
    223230{
  • trunk/WebCore/page/DOMWindow.h

    r28570 r29051  
    142142
    143143        Console* console() const;
     144       
     145        void postMessage(const String& message, const String& domain, const String& uri, DOMWindow* source) const;
    144146
    145147        void scrollBy(int x, int y) const;
  • trunk/WebCore/page/DOMWindow.idl

    r29041 r29051  
    125125
    126126                 attribute [Replaceable] Console console;
     127
     128        // cross-document messaging
     129        [DoNotCheckDomainSecurity, Custom] void postMessage(in DOMString message);
    127130
    128131#if defined(LANGUAGE_JAVASCRIPT)
     
    241244
    242245        attribute EventConstructor Event;
     246        attribute MessageEventConstructor MessageEvent;
    243247        attribute KeyboardEventConstructor KeyboardEvent;
    244248        attribute MouseEventConstructor MouseEvent;
Note: See TracChangeset for help on using the changeset viewer.