Changeset 111098 in webkit


Ignore:
Timestamp:
Mar 16, 2012 5:31:22 PM (12 years ago)
Author:
tsepez@chromium.org
Message:

Make V8 window.open.call(), window.open.showModalDialog() results more closely match JSC.
https://bugs.webkit.org/show_bug.cgi?id=81260
https://bugs.webkit.org/show_bug.cgi?id=39897

Reviewed by Adam Barth.

Source/WebCore:

Tested via http/tests/security/cross-frame-access-call.htm

  • bindings/v8/custom/V8DOMWindowCustom.cpp:

(WebCore::V8DOMWindow::showModalDialogCallback):
(WebCore::V8DOMWindow::openCallback):

LayoutTests:

  • http/tests/security/cross-frame-access-call-expected.txt:
  • http/tests/security/cross-frame-access-call.html:
  • http/tests/security/cross-frame-access-get-expected.txt:
  • http/tests/security/cross-frame-access-get.html:
  • platform/chromium/http/tests/security/aboutBlank/xss-DENIED-set-opener-expected.txt:
  • platform/chromium/http/tests/security/cross-frame-access-call-expected.txt:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r111094 r111098  
     12012-03-16  Tom Sepez  <tsepez@chromium.org>
     2
     3        Make V8 window.open.call(), window.open.showModalDialog() results more closely match JSC.
     4        https://bugs.webkit.org/show_bug.cgi?id=81260
     5        https://bugs.webkit.org/show_bug.cgi?id=39897
     6
     7        Reviewed by Adam Barth.
     8
     9        * http/tests/security/cross-frame-access-call-expected.txt:
     10        * http/tests/security/cross-frame-access-call.html:
     11        * http/tests/security/cross-frame-access-get-expected.txt:
     12        * http/tests/security/cross-frame-access-get.html:
     13        * platform/chromium/http/tests/security/aboutBlank/xss-DENIED-set-opener-expected.txt:
     14        * platform/chromium/http/tests/security/cross-frame-access-call-expected.txt:
     15
    1162012-03-16  Tony Chang  <tony@chromium.org>
    217
  • trunk/LayoutTests/http/tests/security/cross-frame-access-call-expected.txt

    r104803 r111098  
     1CONSOLE MESSAGE: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-call.html. Domains, protocols and ports must match.
     2
    13CONSOLE MESSAGE: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-call.html. Domains, protocols and ports must match.
    24
     
    8385PASS: window.resizeBy.call(targetWindow, 0, 0); should be 'undefined' and is.
    8486PASS: window.resizeTo.call(targetWindow, 0, 0); should be 'undefined' and is.
     87PASS: window.showModalDialog.call(targetWindow); should be 'undefined' and is.
     88PASS: window.eval.call(targetWindow, '1+2'); should be 'EvalError: The "this" value passed to eval must be the global object from which eval originated' and is.
    8589PASS: window.location.toString.call(targetWindow.location) should be 'undefined' and is.
    8690
  • trunk/LayoutTests/http/tests/security/cross-frame-access-call.html

    r70335 r111098  
    5555    shouldBe("window.resizeBy.call(targetWindow, 0, 0);", "undefined");
    5656    shouldBe("window.resizeTo.call(targetWindow, 0, 0);", "undefined");
     57    shouldBe("window.showModalDialog.call(targetWindow);", "undefined");
    5758
    58     // FIXME:  showModalDialog now works on DRT and thus breaks this test.  Will uncomment after adding a separate test for Mac for showModalDialog - Bug #39897
    59     // Throws a TypeError and logs to the error console
    60     // shouldBe("window.showModalDialog.call(targetWindow);", '"TypeError: Result of expression \'window.showModalDialog\' [undefined] is not an object."');
     59    // Throws an EvalError and logs to the error console
     60    shouldBe("window.eval.call(targetWindow, '1+2');", '"EvalError: The \\"this\\" value passed to eval must be the global object from which eval originated"');
    6161
    6262    // - Tests for the Location object -
  • trunk/LayoutTests/http/tests/security/cross-frame-access-get-expected.txt

    r104803 r111098  
     1CONSOLE MESSAGE: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-get.html. Domains, protocols and ports must match.
     2
    13CONSOLE MESSAGE: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-get.html. Domains, protocols and ports must match.
    24
     
    537539PASS: canGet('targetWindow.setInterval') should be 'false' and is.
    538540PASS: canGet('targetWindow.setTimeout') should be 'false' and is.
     541PASS: canGet('targetWindow.showModalDialog') should be 'false' and is.
    539542PASS: canGet('targetWindow.stop') should be 'false' and is.
    540543
  • trunk/LayoutTests/http/tests/security/cross-frame-access-get.html

    r69553 r111098  
    134134            "setInterval",
    135135            "setTimeout",
    136             // FIXME: This function is now implemented on mac and hence the expected output changes.  Uncomment after adding a
    137             // mac specific test for showModalDialog.  Bug# 39897
    138             // "showModalDialog",
     136            "showModalDialog",
    139137            "stop"
    140138        ];
  • trunk/LayoutTests/platform/chromium/http/tests/security/aboutBlank/xss-DENIED-set-opener-expected.txt

    r104803 r111098  
     1CONSOLE MESSAGE: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/innocent-victim.html from frame with URL http://127.0.0.1:8000/security/aboutBlank/xss-DENIED-set-opener.html. Domains, protocols and ports must match.
     2
    13CONSOLE MESSAGE: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/innocent-victim.html from frame with URL http://127.0.0.1:8000/security/aboutBlank/xss-DENIED-set-opener.html. Domains, protocols and ports must match.
    24
  • trunk/LayoutTests/platform/chromium/http/tests/security/cross-frame-access-call-expected.txt

    r108729 r111098  
    2121CONSOLE MESSAGE: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-call.html. Domains, protocols and ports must match.
    2222
    23 CONSOLE MESSAGE: Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL http://127.0.0.1:8000/security/cross-frame-access-call.html. Domains, protocols and ports must match.
     23CONSOLE MESSAGE: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-call.html. Domains, protocols and ports must match.
     24
     25CONSOLE MESSAGE: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-call.html. Domains, protocols and ports must match.
    2426
    2527CONSOLE MESSAGE: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-get-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-call.html. Domains, protocols and ports must match.
     
    6870PASS: window.atob.call(targetWindow, 'string') should be 'undefined' and is.
    6971PASS: window.btoa.call(targetWindow, 'string') should be 'undefined' and is.
    70 *** FAIL: window.open.call(targetWindow, '') should be 'undefined' but instead is [object Window]. ***
     72PASS: window.open.call(targetWindow, '') should be 'undefined' and is.
    7173PASS: window.addEventListener.call(targetWindow, 'load', null, false); should be 'undefined' and is.
    7274PASS: window.removeEventListener.call(targetWindow, 'load', null, false); should be 'undefined' and is.
     
    8385PASS: window.resizeBy.call(targetWindow, 0, 0); should be 'undefined' and is.
    8486PASS: window.resizeTo.call(targetWindow, 0, 0); should be 'undefined' and is.
     87PASS: window.showModalDialog.call(targetWindow); should be 'undefined' and is.
     88*** FAIL: window.eval.call(targetWindow, '1+2'); should be 'EvalError: The "this" value passed to eval must be the global object from which eval originated' but instead is 3. ***
    8589PASS: window.location.toString.call(targetWindow.location) should be 'undefined' and is.
    8690
  • trunk/Source/WebCore/ChangeLog

    r111096 r111098  
     12012-03-16  Tom Sepez  <tsepez@chromium.org>
     2
     3        Make V8 window.open.call(), window.open.showModalDialog() results more closely match JSC.
     4        https://bugs.webkit.org/show_bug.cgi?id=81260
     5        https://bugs.webkit.org/show_bug.cgi?id=39897
     6
     7        Reviewed by Adam Barth.
     8
     9        Tested via http/tests/security/cross-frame-access-call.htm
     10
     11        * bindings/v8/custom/V8DOMWindowCustom.cpp:
     12        (WebCore::V8DOMWindow::showModalDialogCallback):
     13        (WebCore::V8DOMWindow::openCallback):
     14
    1152012-03-16  Matt Lilek  <mrl@apple.com>
    216
  • trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp

    r108700 r111098  
    427427    INC_STATS("DOM.DOMWindow.showModalDialog()");
    428428    DOMWindow* impl = V8DOMWindow::toNative(args.Holder());
    429 
    430429    V8BindingState* state = V8BindingState::Only();
     430    if (!V8BindingSecurity::canAccessFrame(state, impl->frame(), true))
     431        return v8::Undefined();
     432
     433    // FIXME: Handle exceptions properly.
     434    String urlString = toWebCoreStringWithNullOrUndefinedCheck(args[0]);
     435    DialogHandler handler(args[1]);
     436    String dialogFeaturesString = toWebCoreStringWithNullOrUndefinedCheck(args[2]);
    431437
    432438    DOMWindow* activeWindow = state->activeWindow();
    433439    DOMWindow* firstWindow = state->firstWindow();
    434 
    435     // FIXME: Handle exceptions properly.
    436     String urlString = toWebCoreStringWithNullOrUndefinedCheck(args[0]);
    437     String dialogFeaturesString = toWebCoreStringWithNullOrUndefinedCheck(args[2]);
    438 
    439     DialogHandler handler(args[1]);
    440 
    441440    impl->showModalDialog(urlString, dialogFeaturesString, activeWindow, firstWindow, setUpDialog, &handler);
    442441
     
    448447    INC_STATS("DOM.DOMWindow.open()");
    449448    DOMWindow* impl = V8DOMWindow::toNative(args.Holder());
    450 
    451449    V8BindingState* state = V8BindingState::Only();
    452 
    453     DOMWindow* activeWindow = state->activeWindow();
    454     DOMWindow* firstWindow = state->firstWindow();
     450    if (!V8BindingSecurity::canAccessFrame(state, impl->frame(), true))
     451        return v8::Undefined();
    455452
    456453    // FIXME: Handle exceptions properly.
     
    459456    String windowFeaturesString = toWebCoreStringWithNullOrUndefinedCheck(args[2]);
    460457
     458    DOMWindow* activeWindow = state->activeWindow();
     459    DOMWindow* firstWindow = state->firstWindow();
    461460    RefPtr<DOMWindow> openedWindow = impl->open(urlString, frameName, windowFeaturesString, activeWindow, firstWindow);
    462461    if (!openedWindow)
    463462        return v8::Undefined();
     463
    464464    return toV8(openedWindow.release());
    465465}
Note: See TracChangeset for help on using the changeset viewer.