Title: [152859] trunk
Revision
152859
Author
ch.du...@sisa.samsung.com
Date
2013-07-18 12:07:35 -0700 (Thu, 18 Jul 2013)

Log Message

Make atob() / btoa() argument non optional
https://bugs.webkit.org/show_bug.cgi?id=118844

Reviewed by Kentaro Hara.

Source/WebCore:

According to the latest specification, the argument to atob() / btoa()
should not be optional:
http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#windowbase64

This patch makes WebKit behave according to the specification. The argument
is also mandatory in Firefox, IE10 and Blink.

atob() / btoa() are also moved to their own WindowBase64 interface which
the Window interface implements. This does not change the behavior but
this is closer to the specification and it will make exposing those
methods to workers easier later on.

No new tests, already covered by:
fast/dom/Window/atob-btoa.html

* CMakeLists.txt:
* DerivedSources.make:
* DerivedSources.pri:
* GNUmakefile.list.am:
* page/DOMWindow.idl:
* page/WindowBase64.idl: Added.

LayoutTests:

Update and rebaseline fast/dom/Window/atob-btoa.html as atob() /
btoa() 's behavior has changed to match the specification and
the behavior in other browsers.

* fast/dom/Window/atob-btoa-expected.txt:
* fast/dom/Window/atob-btoa.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (152858 => 152859)


--- trunk/LayoutTests/ChangeLog	2013-07-18 18:58:52 UTC (rev 152858)
+++ trunk/LayoutTests/ChangeLog	2013-07-18 19:07:35 UTC (rev 152859)
@@ -1,3 +1,17 @@
+2013-07-18  Christophe Dumez  <ch.du...@sisa.samsung.com>
+
+        Make atob() / btoa() argument non optional
+        https://bugs.webkit.org/show_bug.cgi?id=118844
+
+        Reviewed by Kentaro Hara.
+
+        Update and rebaseline fast/dom/Window/atob-btoa.html as atob() /
+        btoa() 's behavior has changed to match the specification and
+        the behavior in other browsers.
+
+        * fast/dom/Window/atob-btoa-expected.txt:
+        * fast/dom/Window/atob-btoa.html:
+
 2013-07-18  Frédéric Wang  <fred.w...@free.fr>
 
         Convert MathML fraction tests to reftests.

Modified: trunk/LayoutTests/fast/dom/Window/atob-btoa-expected.txt (152858 => 152859)


--- trunk/LayoutTests/fast/dom/Window/atob-btoa-expected.txt	2013-07-18 18:58:52 UTC (rev 152858)
+++ trunk/LayoutTests/fast/dom/Window/atob-btoa-expected.txt	2013-07-18 19:07:35 UTC (rev 152859)
@@ -11,9 +11,9 @@
 PASS window.btoa("abcde") is "YWJjZGU="
 PASS window.btoa("abcdef") is "YWJjZGVm"
 PASS typeof window.btoa is "function"
-PASS window.btoa() is "dW5kZWZpbmVk"
+PASS window.btoa() threw exception TypeError: Not enough arguments.
 PASS window.btoa("") is ""
-PASS window.btoa(null) is ""
+PASS window.btoa(null) is "bnVsbA=="
 PASS window.btoa(undefined) is "dW5kZWZpbmVk"
 PASS window.btoa(window) is "W29iamVjdCBXaW5kb3dd"
 PASS window.btoa("éé") is "6ek="
@@ -22,9 +22,9 @@
 PASS window.btoa is 0
 PASS typeof window.btoa is "number"
 PASS typeof window.atob is "function"
-PASS window.atob() threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS window.atob() threw exception TypeError: Not enough arguments.
 PASS window.atob("") is ""
-PASS window.atob(null) is ""
+PASS window.atob(null) is "žée"
 PASS window.atob(undefined) threw exception Error: InvalidCharacterError: DOM Exception 5.
 PASS window.atob(" YQ==") threw exception Error: InvalidCharacterError: DOM Exception 5.
 PASS window.atob("YQ==\u000a") threw exception Error: InvalidCharacterError: DOM Exception 5.

Modified: trunk/LayoutTests/fast/dom/Window/atob-btoa.html (152858 => 152859)


--- trunk/LayoutTests/fast/dom/Window/atob-btoa.html	2013-07-18 18:58:52 UTC (rev 152858)
+++ trunk/LayoutTests/fast/dom/Window/atob-btoa.html	2013-07-18 19:07:35 UTC (rev 152859)
@@ -19,9 +19,9 @@
 shouldBe('window.btoa("abcdef")', '"YWJjZGVm"');
 
 shouldBe('typeof window.btoa', '"function"');
-shouldBe('window.btoa()', '"dW5kZWZpbmVk"');
+shouldThrow('window.btoa()', '"TypeError: Not enough arguments"');
 shouldBe('window.btoa("")', '""');
-shouldBe('window.btoa(null)', '""');
+shouldBe('window.btoa(null)', '"bnVsbA=="'); // Gets converted to "null" string.
 shouldBe('window.btoa(undefined)', '"dW5kZWZpbmVk"');
 shouldBe('window.btoa(window)', '"W29iamVjdCBXaW5kb3dd"'); // "[object Window]"
 shouldBe('window.btoa("éé")', '"6ek="');
@@ -32,9 +32,9 @@
 shouldBe('typeof window.btoa', '"number"');
 
 shouldBe('typeof window.atob', '"function"');
-shouldThrow('window.atob()'); // 'undefined' 
+shouldThrow('window.atob()', '"TypeError: Not enough arguments"');
 shouldBe('window.atob("")', '""');
-shouldBe('window.atob(null)', '""');
+shouldBe('window.atob(null)', '"\x9Eée"'); // Gets converted to "null" string.
 shouldThrow('window.atob(undefined)');
 shouldThrow('window.atob(" YQ==")');
 shouldThrow('window.atob("YQ==\\u000a")');

Modified: trunk/Source/WebCore/CMakeLists.txt (152858 => 152859)


--- trunk/Source/WebCore/CMakeLists.txt	2013-07-18 18:58:52 UTC (rev 152858)
+++ trunk/Source/WebCore/CMakeLists.txt	2013-07-18 19:07:35 UTC (rev 152859)
@@ -577,6 +577,7 @@
     page/SpeechInputResult.idl
     page/SpeechInputResultList.idl
     page/WebKitPoint.idl
+    page/WindowBase64.idl
     page/WindowTimers.idl
     page/WorkerNavigator.idl
 

Modified: trunk/Source/WebCore/ChangeLog (152858 => 152859)


--- trunk/Source/WebCore/ChangeLog	2013-07-18 18:58:52 UTC (rev 152858)
+++ trunk/Source/WebCore/ChangeLog	2013-07-18 19:07:35 UTC (rev 152859)
@@ -1,3 +1,32 @@
+2013-07-18  Christophe Dumez  <ch.du...@sisa.samsung.com>
+
+        Make atob() / btoa() argument non optional
+        https://bugs.webkit.org/show_bug.cgi?id=118844
+
+        Reviewed by Kentaro Hara.
+
+        According to the latest specification, the argument to atob() / btoa()
+        should not be optional:
+        http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#windowbase64
+
+        This patch makes WebKit behave according to the specification. The argument
+        is also mandatory in Firefox, IE10 and Blink.
+
+        atob() / btoa() are also moved to their own WindowBase64 interface which
+        the Window interface implements. This does not change the behavior but
+        this is closer to the specification and it will make exposing those
+        methods to workers easier later on.
+
+        No new tests, already covered by:
+        fast/dom/Window/atob-btoa.html
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * DerivedSources.pri:
+        * GNUmakefile.list.am:
+        * page/DOMWindow.idl:
+        * page/WindowBase64.idl: Added.
+
 2013-07-18  Antoine Quint  <grao...@apple.com>
 
         Crash in WebCore::createMarkup()

Modified: trunk/Source/WebCore/DerivedSources.make (152858 => 152859)


--- trunk/Source/WebCore/DerivedSources.make	2013-07-18 18:58:52 UTC (rev 152858)
+++ trunk/Source/WebCore/DerivedSources.make	2013-07-18 19:07:35 UTC (rev 152859)
@@ -464,6 +464,7 @@
     $(WebCore)/page/SpeechInputResult.idl \
     $(WebCore)/page/SpeechInputResultList.idl \
     $(WebCore)/page/WebKitPoint.idl \
+    $(WebCore)/page/WindowBase64.idl \
     $(WebCore)/page/WindowTimers.idl \
     $(WebCore)/page/WorkerNavigator.idl \
     $(WebCore)/plugins/DOMMimeType.idl \

Modified: trunk/Source/WebCore/DerivedSources.pri (152858 => 152859)


--- trunk/Source/WebCore/DerivedSources.pri	2013-07-18 18:58:52 UTC (rev 152858)
+++ trunk/Source/WebCore/DerivedSources.pri	2013-07-18 19:07:35 UTC (rev 152859)
@@ -462,6 +462,7 @@
     $$PWD/page/SpeechInputResult.idl \
     $$PWD/page/SpeechInputResultList.idl \
     $$PWD/page/WebKitPoint.idl \
+    $$PWD/page/WindowBase64.idl \
     $$PWD/page/WindowTimers.idl \
     $$PWD/page/WorkerNavigator.idl \
     $$PWD/plugins/DOMPlugin.idl \

Modified: trunk/Source/WebCore/GNUmakefile.list.am (152858 => 152859)


--- trunk/Source/WebCore/GNUmakefile.list.am	2013-07-18 18:58:52 UTC (rev 152858)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2013-07-18 19:07:35 UTC (rev 152859)
@@ -1633,6 +1633,7 @@
 	$(WebCore)/page/SpeechInputResult.idl \
 	$(WebCore)/page/SpeechInputResultList.idl \
 	$(WebCore)/page/WebKitPoint.idl \
+	$(WebCore)/page/WindowBase64.idl \
 	$(WebCore)/page/WindowTimers.idl \
 	$(WebCore)/page/WorkerNavigator.idl \
 	$(WebCore)/plugins/DOMMimeType.idl \

Modified: trunk/Source/WebCore/page/DOMWindow.idl (152858 => 152859)


--- trunk/Source/WebCore/page/DOMWindow.idl	2013-07-18 18:58:52 UTC (rev 152858)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2013-07-18 19:07:35 UTC (rev 152859)
@@ -193,10 +193,6 @@
     [ImplementedAs=cancelAnimationFrame] void webkitCancelRequestAnimationFrame(long id); // This is a deprecated alias for webkitCancelAnimationFrame(). Remove this when removing vendor prefix.
 #endif
 
-    // Base64
-    [RaisesException] DOMString atob([TreatNullAs=NullString,Default=Undefined] optional DOMString string);
-    [RaisesException] DOMString btoa([TreatNullAs=NullString,Default=Undefined] optional DOMString string);
-
     [Replaceable,Conditional=CSS3_CONDITIONAL_RULES] readonly attribute DOMWindowCSS CSS;
 
     // Events
@@ -325,3 +321,4 @@
 };
 
 DOMWindow implements WindowTimers;
+DOMWindow implements WindowBase64;

Added: trunk/Source/WebCore/page/WindowBase64.idl (0 => 152859)


--- trunk/Source/WebCore/page/WindowBase64.idl	                        (rev 0)
+++ trunk/Source/WebCore/page/WindowBase64.idl	2013-07-18 19:07:35 UTC (rev 152859)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Samsung Electronics. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    NoInterfaceObject
+] interface WindowBase64 {
+    [RaisesException] DOMString atob(DOMString string);
+    [RaisesException] DOMString btoa(DOMString string);
+};
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to