<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>31720</bug_id>
          
          <creation_ts>2009-11-20 05:05:42 -0800</creation_ts>
          <short_desc>Incorrect code generated from IDL for document.cookie unless declaration syntax is carefully adjusted</short_desc>
          <delta_ts>2023-12-18 05:01:11 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Patrik Persson">patrik.j.persson</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>annevk</cc>
    
    <cc>ap</cc>
    
    <cc>bfulgham</cc>
    
    <cc>patrik.j.persson</cc>
    
    <cc>sam</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>165279</commentid>
    <comment_count>0</comment_count>
    <who name="Patrik Persson">patrik.j.persson</who>
    <bug_when>2009-11-20 05:05:42 -0800</bug_when>
    <thetext>Some exception specifications for DOM attribute accessors seem to
result in incorrect generated Objective-C++ code. I have seen two
cases, and suspect they are related, so I have bundled them into a
single report.

These cases are both based on an attribute named &apos;cookie&apos;, originally
specified in Document.idl as follows:

  attribute [ConvertNullToNullString] DOMString cookie;

The observed output concerns the generated DOMDocument.mm.

I verified these results on r51076, host Mac OS X 10.6.2.
Nov 20, 2009.


CASE 1
======

The first case was encountered when trying to make the getter raise an
exception, but not the setter. I specified this in Document.idl as
follows:

  attribute [ConvertNullToNullString] DOMString cookie
      getter raises (DOMException);

I would expect the generated DOMDocument.mm to handle exceptions in
the getter, but not the setter. However, it seems to expect an
exception to be raised by the setter as well:

expected:

  - (void)setCookie:(NSString *)newCookie
  {
      IMPL-&gt;setCookie(newCookie);
  }

actual:

  - (void)setCookie:(NSString *)newCookie
  {
      WebCore::ExceptionCode ec = 0;
      IMPL-&gt;setCookie(newCookie, ec);
      WebCore::raiseOnDOMError(ec);
  }

A work-around appears to be to use a &apos;raises&apos; clause with an empty
exception list:

  attribute [ConvertNullToNullString] DOMString cookie
      getter raises (DOMException),
      setter raises (/*DOMException*/);


CASE 2
======

The second case was encountered when trying to make both setter and
getter raise exceptions. I believe this could be specified as follows:

  attribute [ConvertNullToNullString] DOMString cookie
      raises (DOMException);

This also resulted in incorrect generated code (Document.cpp raises
errors, but DOMDocument.mm does not expect them):

expected:

  - (NSString *)cookie
  {
      WebCore::ExceptionCode ec = 0;
      NSString *result = IMPL-&gt;cookie(ec);
      WebCore::raiseOnDOMError(ec);
      return result;
  }

  - (void)setCookie:(NSString *)newCookie
  {
      WebCore::ExceptionCode ec = 0;
      IMPL-&gt;setCookie(newCookie, ec);
      WebCore::raiseOnDOMError(ec);
  }

actual:

  - (NSString *)cookie
  {
      return IMPL-&gt;cookie();
  }

  - (void)setCookie:(NSString *)newCookie
  {
      IMPL-&gt;setCookie(newCookie);
  }

A work-around appears to be separate &apos;raises&apos; clauses for getter and
setter:

  attribute [ConvertNullToNullString] DOMString cookie
      getter raises (DOMException),
      setter raises (DOMException);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1888500</commentid>
    <comment_count>1</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-08-02 14:05:18 -0700</bug_when>
    <thetext>rniwa@webkit.org - I am not sure, this might be needed but can you look into it?

https://github.com/WebKit/WebKit/blob/main/Source/WebCore/dom/Document.idl

I searched &quot;cookie&quot; word but didn&apos;t get it. Further, I know WebIDL specs have been changed a lot from 2009, I don&apos;t know whether these will be applicable or not.

Or this is also applicable with these IDL test cases from WPT:

https://wpt.fyi/results/cookie-store?label=master&amp;label=experimental&amp;aligned&amp;view=subtest&amp;q=cookie

Appreciate if you can share input (also for my learning). Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2000375</commentid>
    <comment_count>2</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-12-18 05:01:11 -0800</bug_when>
    <thetext>From code inspection (Document::setCookie and Document+HTML.idl) this looks correct now.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>