RESOLVED CONFIGURATION CHANGED 31720
Incorrect code generated from IDL for document.cookie unless declaration syntax is carefully adjusted
https://bugs.webkit.org/show_bug.cgi?id=31720
Summary Incorrect code generated from IDL for document.cookie unless declaration synt...
Patrik Persson
Reported 2009-11-20 05:05:42 PST
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 'cookie', 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->setCookie(newCookie); } actual: - (void)setCookie:(NSString *)newCookie { WebCore::ExceptionCode ec = 0; IMPL->setCookie(newCookie, ec); WebCore::raiseOnDOMError(ec); } A work-around appears to be to use a 'raises' 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->cookie(ec); WebCore::raiseOnDOMError(ec); return result; } - (void)setCookie:(NSString *)newCookie { WebCore::ExceptionCode ec = 0; IMPL->setCookie(newCookie, ec); WebCore::raiseOnDOMError(ec); } actual: - (NSString *)cookie { return IMPL->cookie(); } - (void)setCookie:(NSString *)newCookie { IMPL->setCookie(newCookie); } A work-around appears to be separate 'raises' clauses for getter and setter: attribute [ConvertNullToNullString] DOMString cookie getter raises (DOMException), setter raises (DOMException);
Attachments
Ahmad Saleem
Comment 1 2022-08-02 14:05:18 PDT
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 "cookie" word but didn't get it. Further, I know WebIDL specs have been changed a lot from 2009, I don'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&label=experimental&aligned&view=subtest&q=cookie Appreciate if you can share input (also for my learning). Thanks!
Anne van Kesteren
Comment 2 2023-12-18 05:01:11 PST
From code inspection (Document::setCookie and Document+HTML.idl) this looks correct now.
Note You need to log in before you can comment on or make changes to this bug.