⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 280084 in webkit


Ignore:
Timestamp:
Jul 20, 2021, 10:07:58 AM (5 years ago)
Author:
Chris Lord
Message:

Canvas and OffscreenCanvas getContext should check if argument is an object before trying to convert it to a dictionary
https://bugs.webkit.org/show_bug.cgi?id=227792

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

Synchronise with upstream WPT 2d canvas getContext tests.

  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d-getcontext-options.any-expected.txt: Added.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d-getcontext-options.any.html: Added.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d-getcontext-options.any.js: Added.

(test.const.options.get alpha):
(test.const.options.get willReadFrequently):
(test.const.options.get desynchronized):
(test.const.options.get colorSpace):
(test):

  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d-getcontext-options.any.worker-expected.txt: Added.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d-getcontext-options.any.worker.html: Added.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs-expected.txt: Removed.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache-expected.txt: Added.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache.html: Added.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache.worker-expected.txt: Added.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache.worker.html: Added.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache.worker.js: Added.

(t_fail.t.step_func):
(t.step):

  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create-expected.txt: Added.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create.html: Added.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create.worker-expected.txt: Added.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create.worker.html: Added.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create.worker.js: Added.

(t_fail.t.step_func):
(t.step):

  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.html: Removed.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.worker-expected.txt: Removed.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.worker.js: Removed.
  • web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/w3c-import.log:
  • web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d-getcontext-options-expected.txt: Added.
  • web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d-getcontext-options.html: Added.
  • web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.cache-expected.txt: Added.
  • web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.cache.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.html.
  • web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.create-expected.txt: Added.
  • web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.create.html: Added.
  • web-platform-tests/html/semantics/embedded-content/the-canvas-element/w3c-import.log:

Source/WebCore:

Check if options argument is an object before converting to a dictionary.

Tests: imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d-getcontext-options.any.html

imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d-getcontext-options.any.worker.html
imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache.html
imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache.worker.html
imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create.html
imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create.worker.html
imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d-getcontext-options.html
imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.cache.html
imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.create.html

  • html/HTMLCanvasElement.cpp:

(WebCore::HTMLCanvasElement::getContext):

  • html/OffscreenCanvas.cpp:

(WebCore::OffscreenCanvas::getContext):

LayoutTests:

Canvas 2d getContext extraargs tests now pass.

  • platform/glib/TestExpectations:
Location:
trunk
Files:
20 added
4 deleted
8 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r280081 r280084  
     12021-07-20  Chris Lord  <clord@igalia.com>
     2
     3        Canvas and OffscreenCanvas getContext should check if argument is an object before trying to convert it to a dictionary
     4        https://bugs.webkit.org/show_bug.cgi?id=227792
     5
     6        Reviewed by Sam Weinig.
     7
     8        Canvas 2d getContext extraargs tests now pass.
     9
     10        * platform/glib/TestExpectations:
     11
    1122021-07-20  Sam Sneddon  <gsnedders@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r280081 r280084  
     12021-07-20  Chris Lord  <clord@igalia.com>
     2
     3        Canvas and OffscreenCanvas getContext should check if argument is an object before trying to convert it to a dictionary
     4        https://bugs.webkit.org/show_bug.cgi?id=227792
     5
     6        Reviewed by Sam Weinig.
     7
     8        Synchronise with upstream WPT 2d canvas getContext tests.
     9
     10        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d-getcontext-options.any-expected.txt: Added.
     11        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d-getcontext-options.any.html: Added.
     12        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d-getcontext-options.any.js: Added.
     13        (test.const.options.get alpha):
     14        (test.const.options.get willReadFrequently):
     15        (test.const.options.get desynchronized):
     16        (test.const.options.get colorSpace):
     17        (test):
     18        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d-getcontext-options.any.worker-expected.txt: Added.
     19        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d-getcontext-options.any.worker.html: Added.
     20        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs-expected.txt: Removed.
     21        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache-expected.txt: Added.
     22        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache.html: Added.
     23        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache.worker-expected.txt: Added.
     24        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache.worker.html: Added.
     25        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache.worker.js: Added.
     26        (t_fail.t.step_func):
     27        (t.step):
     28        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create-expected.txt: Added.
     29        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create.html: Added.
     30        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create.worker-expected.txt: Added.
     31        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create.worker.html: Added.
     32        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create.worker.js: Added.
     33        (t_fail.t.step_func):
     34        (t.step):
     35        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.html: Removed.
     36        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.worker-expected.txt: Removed.
     37        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.worker.js: Removed.
     38        * web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/w3c-import.log:
     39        * web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d-getcontext-options-expected.txt: Added.
     40        * web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d-getcontext-options.html: Added.
     41        * web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.cache-expected.txt: Added.
     42        * web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.cache.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.html.
     43        * web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.create-expected.txt: Added.
     44        * web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.create.html: Added.
     45        * web-platform-tests/html/semantics/embedded-content/the-canvas-element/w3c-import.log:
     46
    1472021-07-20  Sam Sneddon  <gsnedders@apple.com>
    248
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/w3c-import.log

    r264117 r280084  
    1515------------------------------------------------------------------------
    1616List of files:
     17/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d-getcontext-options.any.js
    1718/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.canvas.readonly.html
    1819/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.canvas.readonly.worker.js
     
    2122/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.exists.html
    2223/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.exists.worker.js
    23 /LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.html
    24 /LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.worker.js
     24/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache.html
     25/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache.worker.js
     26/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create.html
     27/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create.worker.js
    2528/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.shared.html
    2629/LayoutTests/imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.shared.worker.js
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.cache.html

    r280083 r280084  
    11<!DOCTYPE html>
    22<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
    3 <title>Canvas test: 2d.getcontext.extraargs</title>
     3<title>Canvas test: 2d.getcontext.extraargs.cache</title>
    44<script src="/resources/testharness.js"></script>
    55<script src="/resources/testharnessreport.js"></script>
     
    88<body class="show_output">
    99
    10 <h1>2d.getcontext.extraargs</h1>
    11 <p class="desc">The 2D context ignores extra getContext arguments</p>
     10<h1>2d.getcontext.extraargs.cache</h1>
     11<p class="desc">The 2D context doesn't throw with extra getContext arguments (cached)</p>
    1212
    1313
     
    1717<ul id="d"></ul>
    1818<script>
    19 var t = async_test("The 2D context ignores extra getContext arguments");
     19var t = async_test("The 2D context doesn't throw with extra getContext arguments (cached)");
    2020_addTest(function(canvas, ctx) {
    2121
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/w3c-import.log

    r269598 r280084  
    1515------------------------------------------------------------------------
    1616List of files:
     17/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d-getcontext-options.html
    1718/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.canvas.context.html
    1819/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.canvas.readonly.html
    1920/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.canvas.reference.html
    2021/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.exists.html
    21 /LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.html
     22/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.cache.html
     23/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.create.html
    2224/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.invalid.args.html
    2325/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.shared.html
  • trunk/LayoutTests/platform/glib/TestExpectations

    r279940 r280084  
    764764# Failing since r277543.
    765765webkit.org/b/225870 imported/w3c/web-platform-tests/html/canvas/offscreen/fill-and-stroke-styles/2d.gradient.conic.worker.html [ Failure ]
    766 webkit.org/b/225870 imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.html [ Failure ]
    767 webkit.org/b/225870 imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.worker.html [ Failure ]
    768766
    769767#////////////////////////////////////////////////////////////////////////////////////////
  • trunk/Source/WebCore/ChangeLog

    r280083 r280084  
     12021-07-20  Chris Lord  <clord@igalia.com>
     2
     3        Canvas and OffscreenCanvas getContext should check if argument is an object before trying to convert it to a dictionary
     4        https://bugs.webkit.org/show_bug.cgi?id=227792
     5
     6        Reviewed by Sam Weinig.
     7
     8        Check if options argument is an object before converting to a dictionary.
     9
     10        Tests: imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d-getcontext-options.any.html
     11               imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d-getcontext-options.any.worker.html
     12               imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache.html
     13               imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.cache.worker.html
     14               imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create.html
     15               imported/w3c/web-platform-tests/html/canvas/offscreen/the-offscreen-canvas/2d.getcontext.extraargs.create.worker.html
     16               imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d-getcontext-options.html
     17               imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.cache.html
     18               imported/w3c/web-platform-tests/html/semantics/embedded-content/the-canvas-element/2d.getcontext.extraargs.create.html
     19
     20        * html/HTMLCanvasElement.cpp:
     21        (WebCore::HTMLCanvasElement::getContext):
     22        * html/OffscreenCanvas.cpp:
     23        (WebCore::OffscreenCanvas::getContext):
     24
    1252021-07-20  Alex Christensen  <achristensen@webkit.org>
    226
  • trunk/Source/WebCore/html/HTMLCanvasElement.cpp

    r280020 r280084  
    285285    if (is2dType(contextId)) {
    286286        auto scope = DECLARE_THROW_SCOPE(state.vm());
    287         auto settings = convert<IDLDictionary<CanvasRenderingContext2DSettings>>(state, !arguments.isEmpty() ? arguments[0].get() : JSC::jsUndefined());
     287        auto settings = convert<IDLDictionary<CanvasRenderingContext2DSettings>>(state, arguments.isEmpty() ? JSC::jsUndefined() : (arguments[0].isObject() ? arguments[0].get() : JSC::jsNull()));
    288288        RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
    289289
     
    296296    if (isBitmapRendererType(contextId)) {
    297297        auto scope = DECLARE_THROW_SCOPE(state.vm());
    298         auto settings = convert<IDLDictionary<ImageBitmapRenderingContextSettings>>(state, !arguments.isEmpty() ? arguments[0].get() : JSC::jsUndefined());
     298        auto settings = convert<IDLDictionary<ImageBitmapRenderingContextSettings>>(state, arguments.isEmpty() ? JSC::jsUndefined() : (arguments[0].isObject() ? arguments[0].get() : JSC::jsNull()));
    299299        RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
    300300
     
    308308    if (isWebGLType(contextId)) {
    309309        auto scope = DECLARE_THROW_SCOPE(state.vm());
    310         auto attributes = convert<IDLDictionary<WebGLContextAttributes>>(state, !arguments.isEmpty() ? arguments[0].get() : JSC::jsUndefined());
     310        auto attributes = convert<IDLDictionary<WebGLContextAttributes>>(state, arguments.isEmpty() ? JSC::jsUndefined() : (arguments[0].isObject() ? arguments[0].get() : JSC::jsNull()));
    311311        RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
    312312
  • trunk/Source/WebCore/html/OffscreenCanvas.cpp

    r278253 r280084  
    227227
    228228        auto scope = DECLARE_THROW_SCOPE(state.vm());
    229         auto settings = convert<IDLDictionary<CanvasRenderingContext2DSettings>>(state, !arguments.isEmpty() ? arguments[0].get() : JSC::jsUndefined());
     229        auto settings = convert<IDLDictionary<CanvasRenderingContext2DSettings>>(state, arguments.isEmpty() ? JSC::jsUndefined() : (arguments[0].isObject() ? arguments[0].get() : JSC::jsNull()));
    230230        RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
    231231
     
    249249
    250250        auto scope = DECLARE_THROW_SCOPE(state.vm());
    251         auto attributes = convert<IDLDictionary<WebGLContextAttributes>>(state, !arguments.isEmpty() ? arguments[0].get() : JSC::jsUndefined());
     251        auto attributes = convert<IDLDictionary<WebGLContextAttributes>>(state, arguments.isEmpty() ? JSC::jsUndefined() : (arguments[0].isObject() ? arguments[0].get() : JSC::jsNull()));
    252252        RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
    253253
Note: See TracChangeset for help on using the changeset viewer.