Changeset 50607 in webkit


Ignore:
Timestamp:
Nov 6, 2009 3:00:44 PM (14 years ago)
Author:
eric@webkit.org
Message:

2009-11-06 Anantanarayanan G Iyengar <ananta@chromium.org>

Reviewed by Adam Barth.

Added layout tests to test document.open and window.open calls issued
by NPAPI plugins without a calling javascript context. The associated
webkit bug is https://bugs.webkit.org/show_bug.cgi?id=31067, which
affects Chromium.

  • plugins/document-open-expected.txt: Added.
  • plugins/document-open.html: Added.
  • plugins/window-open-expected.txt: Added.
  • plugins/window-open.html: Added.

2009-11-06 Anantanarayanan G Iyengar <ananta@chromium.org>

Reviewed by Adam Barth.

The associated webkit bug is https://bugs.webkit.org/show_bug.cgi?id=31067,
which affects Chromium only.

Changes to V8HTMLDocumentCustom.cpp are as below:-

  1. The HTMLDocumentOpen function would cause a crash in Chromium if there was no calling javascript context. We now check for this case and pass in NULL to the HTMLDocument::open function which can handle a NULL document parameter.
  2. The other functions like HTMLDocumentWrite, HTMLDocumentWriteln, etc had ASSERTS for a NULL caller frame, which was bogus as it would crash anyway. We now check for this case and return a failure.

Changes to V8DOMWindowCustom.cpp are as below:-

  1. Instead of failing the window.open call made by NPAPI for lack of a calling javascript context, we now use the entered context as the calling context.

Tests: plugins/document-open.html

plugins/window-open.html

  • bindings/v8/custom/V8DOMWindowCustom.cpp: (WebCore::CALLBACK_FUNC_DECL):
  • bindings/v8/custom/V8HTMLDocumentCustom.cpp: (WebCore::CALLBACK_FUNC_DECL):

2009-11-06 Anantanarayanan G Iyengar <ananta@chromium.org>

Reviewed by Adam Barth.

Added functionality to the layout test plugin to invoke document.open and
window.open with default arguments. The associated webkit bug is
https://bugs.webkit.org/show_bug.cgi?id=31067, which affects Chromium. Basically
window.open and document.open calls issued by NPAPI plugins via NPN_Invoke don't
work in Chromium (V8) if there is no calling javascript context. To achieve this
effect we invoke these functions in the layout test plugin in the NPP_SetWindow
for the window.open test case and in NPP_DestroyStream for the document.open test case.

  • DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp: (testDocumentOpen): (testWindowOpen): (pluginAllocate):
  • DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h:
  • DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp: (NPP_New): (NPP_SetWindow): (NPP_DestroyStream):
  • DumpRenderTree/win/TestNetscapePlugin/main.cpp: (NPP_New): (NPP_SetWindow): (NPP_NewStream): (NPP_DestroyStream):
Location:
trunk
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r50605 r50607  
     12009-11-06  Anantanarayanan G Iyengar  <ananta@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Added layout tests to test document.open and window.open calls issued
     6        by NPAPI plugins without a calling javascript context. The associated
     7        webkit bug is https://bugs.webkit.org/show_bug.cgi?id=31067, which
     8        affects Chromium.
     9
     10        * plugins/document-open-expected.txt: Added.
     11        * plugins/document-open.html: Added.
     12        * plugins/window-open-expected.txt: Added.
     13        * plugins/window-open.html: Added.
     14
    1152009-11-06  Steve Block  <steveblock@google.com>
    216
  • trunk/WebCore/ChangeLog

    r50605 r50607  
     12009-11-06  Anantanarayanan G Iyengar  <ananta@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        The associated webkit bug is https://bugs.webkit.org/show_bug.cgi?id=31067,
     6        which affects Chromium only.
     7       
     8        Changes to V8HTMLDocumentCustom.cpp are as below:-
     9        1. The HTMLDocumentOpen function would cause a crash in Chromium if
     10           there was no calling javascript context. We now check for this case
     11           and pass in NULL to the HTMLDocument::open function which can handle
     12           a NULL document parameter.
     13        2. The other functions like HTMLDocumentWrite, HTMLDocumentWriteln, etc
     14           had ASSERTS for a NULL caller frame, which was bogus as it would crash
     15           anyway. We now check for this case and return a failure.
     16           
     17        Changes to V8DOMWindowCustom.cpp are as below:-
     18        1. Instead of failing the window.open call made by NPAPI for lack of a
     19           calling javascript context, we now use the entered context as the calling
     20           context.
     21
     22        Tests: plugins/document-open.html
     23               plugins/window-open.html
     24
     25        * bindings/v8/custom/V8DOMWindowCustom.cpp:
     26        (WebCore::CALLBACK_FUNC_DECL):
     27        * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
     28        (WebCore::CALLBACK_FUNC_DECL):
     29
    1302009-11-06  Steve Block  <steveblock@google.com>
    231
  • trunk/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp

    r50603 r50607  
    703703        return v8::Undefined();
    704704
    705     Frame* callingFrame = V8Proxy::retrieveFrameForCallingContext();
    706     if (!callingFrame)
    707         return v8::Undefined();
    708 
    709705    Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
    710706    if (!enteredFrame)
    711707        return v8::Undefined();
     708
     709    Frame* callingFrame = V8Proxy::retrieveFrameForCallingContext();
     710    // We may not have a calling context if we are invoked by a plugin via NPAPI.
     711    if (!callingFrame)
     712        callingFrame = enteredFrame;
    712713
    713714    Page* page = frame->page();
  • trunk/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp

    r50027 r50607  
    121121    HTMLDocument* htmlDocument = V8DOMWrapper::convertDOMWrapperToNode<HTMLDocument>(args.Holder());
    122122    Frame* frame = V8Proxy::retrieveFrameForCallingContext();
    123     ASSERT(frame);
    124     htmlDocument->write(writeHelperGetString(args), frame->document());
     123    htmlDocument->write(writeHelperGetString(args), frame ? frame->document() : NULL);
    125124    return v8::Undefined();
    126125}
     
    131130    HTMLDocument* htmlDocument = V8DOMWrapper::convertDOMWrapperToNode<HTMLDocument>(args.Holder());
    132131    Frame* frame = V8Proxy::retrieveFrameForCallingContext();
    133     ASSERT(frame);
    134     htmlDocument->writeln(writeHelperGetString(args), frame->document());
     132    htmlDocument->writeln(writeHelperGetString(args), frame ? frame->document() : NULL);
    135133    return v8::Undefined();
    136134}
     
    171169
    172170    Frame* frame = V8Proxy::retrieveFrameForCallingContext();
    173     htmlDocument->open(frame->document());
     171    htmlDocument->open(frame ? frame->document() : NULL);
    174172    // Return the document.
    175173    return args.Holder();
  • trunk/WebKitTools/ChangeLog

    r50602 r50607  
     12009-11-06  Anantanarayanan G Iyengar  <ananta@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Added functionality to the layout test plugin to invoke document.open and
     6        window.open with default arguments. The associated webkit bug is
     7        https://bugs.webkit.org/show_bug.cgi?id=31067, which affects Chromium. Basically
     8        window.open and document.open calls issued by NPAPI plugins via NPN_Invoke don't
     9        work in Chromium (V8) if there is no calling javascript context. To achieve this
     10        effect we invoke these functions in the layout test plugin in the NPP_SetWindow
     11        for the window.open test case and in NPP_DestroyStream for the document.open test case.
     12
     13        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp:
     14        (testDocumentOpen):
     15        (testWindowOpen):
     16        (pluginAllocate):
     17        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h:
     18        * DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp:
     19        (NPP_New):
     20        (NPP_SetWindow):
     21        (NPP_DestroyStream):
     22        * DumpRenderTree/win/TestNetscapePlugin/main.cpp:
     23        (NPP_New):
     24        (NPP_SetWindow):
     25        (NPP_NewStream):
     26        (NPP_DestroyStream):
     27
    1282009-11-06  Eric Seidel  <eric@webkit.org>
    229
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp

    r50470 r50607  
    642642   
    643643    return browser->construct(obj->npp, NPVARIANT_TO_OBJECT(args[0]), args + 1, argCount - 1, result);
     644}
     645
     646bool testDocumentOpen(NPP npp) {
     647    NPIdentifier documentId = browser->getstringidentifier("document");
     648    NPIdentifier openId = browser->getstringidentifier("open");
     649
     650    NPObject *windowObject = NULL;
     651    browser->getvalue(npp, NPNVWindowNPObject, &windowObject);
     652    if (!windowObject)
     653        return false;
     654
     655    NPVariant docVariant;
     656    browser->getproperty(npp, windowObject, documentId, &docVariant);
     657    if (docVariant.type != NPVariantType_Object)
     658        return false;
     659
     660    NPObject *documentObject = NPVARIANT_TO_OBJECT(docVariant);
     661
     662    NPVariant openArgs[2];
     663    STRINGZ_TO_NPVARIANT("text/html", openArgs[0]);
     664    STRINGZ_TO_NPVARIANT("_blank", openArgs[1]);
     665
     666    NPVariant result;
     667    browser->invoke(npp, documentObject, openId, openArgs, 2, &result);
     668    browser->releaseobject(documentObject);
     669
     670    if (result.type == NPVariantType_Object) {
     671        browser->releaseobject(result.value.objectValue);
     672        pluginLog(npp, "DOCUMENT OPEN SUCCESS");
     673        return true;
     674    }
     675    return false;
     676}
     677
     678bool testWindowOpen(NPP npp) {
     679    NPIdentifier openId = browser->getstringidentifier("open");
     680
     681    NPObject *windowObject = NULL;
     682    browser->getvalue(npp, NPNVWindowNPObject, &windowObject);
     683    if (!windowObject)
     684        return false;
     685
     686    NPVariant openArgs[2];
     687    STRINGZ_TO_NPVARIANT("about:blank", openArgs[0]);
     688    STRINGZ_TO_NPVARIANT("_blank", openArgs[1]);
     689
     690    NPVariant result;
     691    browser->invoke(npp, windowObject, openId, openArgs, 2, &result);
     692    if (result.type == NPVariantType_Object) {
     693        browser->releaseobject(result.value.objectValue);
     694        pluginLog(npp, "WINDOW OPEN SUCCESS");
     695        return true;
     696    }
     697    return false;
    644698}
    645699
     
    734788    newInstance->lastHeaders = NULL;
    735789
     790    newInstance->testDocumentOpenInDestroyStream = FALSE;
     791    newInstance->testWindowOpen = FALSE;
     792
    736793    return (NPObject*)newInstance;
    737794}
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h

    r50470 r50607  
    3939    NPObject* testObject;
    4040    NPStream* stream;
     41    NPBool testDocumentOpenInDestroyStream;
     42    NPBool testWindowOpen;
    4143    char* onStreamLoad;
    4244    char* onStreamDestroy;
     
    5759extern void testNPRuntime(NPP npp);
    5860extern void pluginLog(NPP instance, const char* format, ...);
     61extern bool testDocumentOpen(NPP npp);
     62extern bool testWindowOpen(NPP npp);
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp

    r50470 r50607  
    108108        else if (!strcasecmp(argn[i], "ondestroy"))
    109109            obj->onDestroy = strdup(argv[i]);
     110        else if (strcasecmp(argn[i], "testdocumentopenindestroystream") == 0)
     111            obj->testDocumentOpenInDestroyStream = TRUE;
     112        else if (strcasecmp(argn[i], "testwindowopen") == 0)
     113            obj->testWindowOpen = TRUE;
    110114    }
    111115       
     
    174178            obj->logSetWindow = false;
    175179        }
     180
     181        if (obj->testWindowOpen) {
     182            testWindowOpen(instance);
     183            obj->testWindowOpen = FALSE;
     184        }
    176185    }
    177186   
     
    217226    if (obj->onStreamDestroy)
    218227        executeScript(obj, obj->onStreamDestroy);
     228
     229    if (obj->testDocumentOpenInDestroyStream) {
     230        testDocumentOpen(instance);
     231        obj->testDocumentOpenInDestroyStream = FALSE;
     232    }
    219233
    220234    return NPERR_NO_ERROR;
  • trunk/WebKitTools/DumpRenderTree/win/TestNetscapePlugin/main.cpp

    r45324 r50607  
    8989                    if (_stricmp(argn[i], "src") == 0)
    9090                        pluginLog(instance, "src: %s", argv[i]);
    91             }
     91            } else if (_stricmp(argn[i], "testdocumentopenindestroystream") == 0)
     92                obj->testDocumentOpenInDestroyStream = TRUE;
     93              else if (_stricmp(argn[i], "testwindowopen") == 0)
     94                obj->testWindowOpen = TRUE;
    9295        }
    9396       
    9497        instance->pdata = obj;
    9598    }
    96    
     99
    97100    return NPERR_NO_ERROR;
    98101}
     
    121124NPError NPP_SetWindow(NPP instance, NPWindow *window)
    122125{
     126    PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
     127
     128    if (obj) {
     129        if (obj->testWindowOpen) {
     130            testWindowOpen(instance);
     131            obj->testWindowOpen = FALSE;
     132        }
     133    }
     134
    123135    return NPERR_NO_ERROR;
    124136}
     
    150162    if (obj->onStreamLoad)
    151163        executeScript(obj, obj->onStreamLoad);
    152    
     164
    153165    return NPERR_NO_ERROR;
    154166}
     
    160172    if (obj->onStreamDestroy)
    161173        executeScript(obj, obj->onStreamDestroy);
     174
     175    if (obj->testDocumentOpenInDestroyStream) {
     176        testDocumentOpen(instance);
     177    }
    162178
    163179    return NPERR_NO_ERROR;
Note: See TracChangeset for help on using the changeset viewer.