Changeset 292229 in webkit


Ignore:
Timestamp:
Apr 1, 2022 12:26:41 PM (4 months ago)
Author:
Kate Cheney
Message:

CSP: WASM fails to execute after window.open
https://bugs.webkit.org/show_bug.cgi?id=238562
<rdar://problem/90778752>

Reviewed by Brent Fulgham.

Source/WebCore:

Test: http/tests/security/contentSecurityPolicy/allow-wasm-after-window-open.html

Reset WASM enabled value after a window.open() call. This patch simplifies
eval and wasm setters by removing the distinct enable/disable functions
and using one consistent setter.

  • bindings/js/ScriptController.cpp:

(WebCore::ScriptController::setEvalEnabled):
(WebCore::ScriptController::setWebAssemblyEnabled):
(WebCore::ScriptController::enableEval): Deleted.
(WebCore::ScriptController::enableWebAssembly): Deleted.
(WebCore::ScriptController::disableEval): Deleted.
(WebCore::ScriptController::disableWebAssembly): Deleted.

  • bindings/js/ScriptController.h:
  • dom/Document.cpp:

(WebCore::Document::disableEval):
(WebCore::Document::disableWebAssembly):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::clear):

  • page/csp/ContentSecurityPolicy.h:

(WebCore::ContentSecurityPolicy::webAssemblyErrorMessage const):

LayoutTests:

Layout test coverage. Copy some wasm helper scripts into the http directory.

  • platform/win/TestExpectations:

We don't support wasm on win.

  • http/tests/security/contentSecurityPolicy/allow-wasm-after-window-open-expected.txt: Added.
  • http/tests/security/contentSecurityPolicy/allow-wasm-after-window-open.html: Added.
  • http/tests/security/contentSecurityPolicy/resources/load_wasm.js: Added.

(createWasmModule):

  • http/tests/security/contentSecurityPolicy/resources/run-web-assembly.html: Added.
  • http/tests/security/contentSecurityPolicy/resources/wasm-builder.js: Added.

(const._fail):
(const.isNotA.assert.isNotA):
(const):
(switch.typeof):
(Builder):
(Builder.prototype.setChecked):
(Builder.prototype.setPreamble):
(Builder.prototype._functionIndexSpaceKeyHash):
(Builder.prototype._registerFunctionToIndexSpace):
(Builder.prototype._getFunctionFromIndexSpace):
(Builder.prototype._registerSectionBuilders.const.section.in.WASM.description.section.switch.section.case.string_appeared_here.this.section):
(Builder.prototype._registerSectionBuilders.const.section.in.WASM.description.section.switch.section.const.codeBuilder.End.switch.case.string_appeared_here.e):
(Builder.prototype._registerSectionBuilders.this.Unknown):

Location:
trunk
Files:
5 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r292226 r292229  
     12022-04-01  Kate Cheney  <katherine_cheney@apple.com>
     2
     3        CSP: WASM fails to execute after window.open
     4        https://bugs.webkit.org/show_bug.cgi?id=238562
     5        <rdar://problem/90778752>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Layout test coverage. Copy some wasm helper scripts into the http directory.
     10
     11        * platform/win/TestExpectations:
     12        We don't support wasm on win.       
     13
     14        * http/tests/security/contentSecurityPolicy/allow-wasm-after-window-open-expected.txt: Added.
     15        * http/tests/security/contentSecurityPolicy/allow-wasm-after-window-open.html: Added.
     16        * http/tests/security/contentSecurityPolicy/resources/load_wasm.js: Added.
     17        (createWasmModule):
     18        * http/tests/security/contentSecurityPolicy/resources/run-web-assembly.html: Added.
     19        * http/tests/security/contentSecurityPolicy/resources/wasm-builder.js: Added.
     20        (const._fail):
     21        (const.isNotA.assert.isNotA):
     22        (const):
     23        (switch.typeof):
     24        (Builder):
     25        (Builder.prototype.setChecked):
     26        (Builder.prototype.setPreamble):
     27        (Builder.prototype._functionIndexSpaceKeyHash):
     28        (Builder.prototype._registerFunctionToIndexSpace):
     29        (Builder.prototype._getFunctionFromIndexSpace):
     30        (Builder.prototype._registerSectionBuilders.const.section.in.WASM.description.section.switch.section.case.string_appeared_here.this.section):
     31        (Builder.prototype._registerSectionBuilders.const.section.in.WASM.description.section.switch.section.const.codeBuilder.End.switch.case.string_appeared_here.e):
     32        (Builder.prototype._registerSectionBuilders.this.Unknown):
     33
    1342022-04-01  Alan Bujtas  <zalan@apple.com>
    235
  • trunk/LayoutTests/platform/win/TestExpectations

    r292086 r292229  
    39023902imported/w3c/web-platform-tests/wasm/wasm_stream_instantiate_test.html  [ Skip ]
    39033903imported/w3c/web-platform-tests/wasm/wasm_stream_compile_test.html  [ Skip ]
     3904http/tests/security/contentSecurityPolicy/allow-wasm-after-window-open.html [ Skip ]
    39043905
    39053906# Animated image throttling behaves differently on WK1.
  • trunk/Source/WebCore/ChangeLog

    r292228 r292229  
     12022-04-01  Kate Cheney  <katherine_cheney@apple.com>
     2
     3        CSP: WASM fails to execute after window.open
     4        https://bugs.webkit.org/show_bug.cgi?id=238562
     5        <rdar://problem/90778752>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Test: http/tests/security/contentSecurityPolicy/allow-wasm-after-window-open.html
     10
     11        Reset WASM enabled value after a window.open() call. This patch simplifies
     12        eval and wasm setters by removing the distinct enable/disable functions
     13        and using one consistent setter.
     14
     15        * bindings/js/ScriptController.cpp:
     16        (WebCore::ScriptController::setEvalEnabled):
     17        (WebCore::ScriptController::setWebAssemblyEnabled):
     18        (WebCore::ScriptController::enableEval): Deleted.
     19        (WebCore::ScriptController::enableWebAssembly): Deleted.
     20        (WebCore::ScriptController::disableEval): Deleted.
     21        (WebCore::ScriptController::disableWebAssembly): Deleted.
     22        * bindings/js/ScriptController.h:
     23        * dom/Document.cpp:
     24        (WebCore::Document::disableEval):
     25        (WebCore::Document::disableWebAssembly):
     26        * loader/FrameLoader.cpp:
     27        (WebCore::FrameLoader::clear):
     28        * page/csp/ContentSecurityPolicy.h:
     29        (WebCore::ContentSecurityPolicy::webAssemblyErrorMessage const):
     30
    1312022-04-01  Alan Bujtas  <zalan@apple.com>
    232
  • trunk/Source/WebCore/bindings/js/ScriptController.cpp

    r291863 r292229  
    407407}
    408408
    409 void ScriptController::enableEval(bool enable, const String& errorMessage)
     409void ScriptController::setEvalEnabled(bool value, const String& errorMessage)
    410410{
    411411    auto* jsWindowProxy = windowProxy().existingJSWindowProxy(mainThreadNormalWorld());
    412412    if (!jsWindowProxy)
    413413        return;
    414     jsWindowProxy->window()->setEvalEnabled(enable, errorMessage);
    415 }
    416 
    417 void ScriptController::enableWebAssembly()
     414    jsWindowProxy->window()->setEvalEnabled(value, errorMessage);
     415}
     416
     417void ScriptController::setWebAssemblyEnabled(bool value, const String& errorMessage)
    418418{
    419419    auto* jsWindowProxy = windowProxy().existingJSWindowProxy(mainThreadNormalWorld());
    420420    if (!jsWindowProxy)
    421421        return;
    422     jsWindowProxy->window()->setWebAssemblyEnabled(true);
    423 }
    424 
    425 void ScriptController::disableEval(const String& errorMessage)
    426 {
    427     auto* jsWindowProxy = windowProxy().existingJSWindowProxy(mainThreadNormalWorld());
    428     if (!jsWindowProxy)
    429         return;
    430     jsWindowProxy->window()->setEvalEnabled(false, errorMessage);
    431 }
    432 
    433 void ScriptController::disableWebAssembly(const String& errorMessage)
    434 {
    435     auto* jsWindowProxy = windowProxy().existingJSWindowProxy(mainThreadNormalWorld());
    436     if (!jsWindowProxy)
    437         return;
    438     jsWindowProxy->window()->setWebAssemblyEnabled(false, errorMessage);
     422    jsWindowProxy->window()->setWebAssemblyEnabled(value, errorMessage);
    439423}
    440424
  • trunk/Source/WebCore/bindings/js/ScriptController.h

    r290853 r292229  
    125125    TextPosition eventHandlerPosition() const;
    126126
    127     void enableEval(bool, const String& errorMessage = String());
    128     void enableWebAssembly();
    129     void disableEval(const String& errorMessage);
    130     void disableWebAssembly(const String& errorMessage);
     127    void setEvalEnabled(bool, const String& errorMessage = String());
     128    void setWebAssemblyEnabled(bool, const String& errorMessage = String());
    131129
    132130    static bool canAccessFromCurrentOrigin(Frame*, Document& accessingDocument);
  • trunk/Source/WebCore/dom/Document.cpp

    r292057 r292229  
    35683568        return;
    35693569
    3570     frame()->script().disableEval(errorMessage);
     3570    frame()->script().setEvalEnabled(false, errorMessage);
    35713571}
    35723572
     
    35763576        return;
    35773577
    3578     frame()->script().disableWebAssembly(errorMessage);
     3578    frame()->script().setWebAssemblyEnabled(false, errorMessage);
    35793579}
    35803580
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r292002 r292229  
    668668        m_frame.script().clearScriptObjects();
    669669
    670     if (newDocument->contentSecurityPolicy() && !newDocument->contentSecurityPolicy()->evalErrorMessage().isNull())
    671         m_frame.script().enableEval(false, newDocument->contentSecurityPolicy()->evalErrorMessage());
    672     else
    673         m_frame.script().enableEval(true);
     670    if (newDocument->contentSecurityPolicy()) {
     671        bool enableEvalValue = newDocument->contentSecurityPolicy()->evalErrorMessage().isNull();
     672        bool enableWASMValue = newDocument->contentSecurityPolicy()->webAssemblyErrorMessage().isNull();
     673        m_frame.script().setEvalEnabled(enableEvalValue, newDocument->contentSecurityPolicy()->evalErrorMessage());
     674        m_frame.script().setWebAssemblyEnabled(enableWASMValue, newDocument->contentSecurityPolicy()->webAssemblyErrorMessage());
     675    }
    674676
    675677    m_frame.navigationScheduler().clear();
  • trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h

    r292134 r292229  
    199199
    200200    const String& evalErrorMessage() const { return m_lastPolicyEvalDisabledErrorMessage; }
     201    const String& webAssemblyErrorMessage() const { return m_lastPolicyWebAssemblyDisabledErrorMessage; }
    201202
    202203    ContentSecurityPolicyModeForExtension contentSecurityPolicyModeForExtension() const { return m_contentSecurityPolicyModeForExtension; }
Note: See TracChangeset for help on using the changeset viewer.