[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00
eric at webkit.org
eric at webkit.org
Wed Mar 17 18:26:09 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 512620f50c1d2ec8265783e5246aebbee8c3ee29
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Mar 6 13:03:52 2010 +0000
2010-03-06 MORITA Hajime <morrita at google.com>
Reviewed by Darin Adler.
Moved implementations of window.btoa() and window.atob() from
JSDOMWindow to DOMWindow, and make V8DOMWindow use DOMWindow
functions instead of having a separate implementation. As a side effect, the
error message has changed from "Cannot decode base64" to one that
indicates DOM Exception, which is compatible to Firefox.
Refactoring: window.btoa() and window.atob() should be implemented on DOMWindow
https://bugs.webkit.org/show_bug.cgi?id=35723
* fast/dom/Window/atob-btoa-expected.txt:
Rebaselined expectation due to change of error message.
2010-03-06 MORITA Hajime <morrita at google.com>
Reviewed by Darin Adler.
Moved implementations of window.btoa() and window.atob() from
JSDOMWindow to DOMWindow, and make V8DOMWindow use DOMWindow
functions instead of having a separate implementation. As a side effect, the
error message has changed from "Cannot decode base64" to one that
indicates DOM Exception, which is compatible to Firefox.
Refactoring: window.btoa() and window.atob() should be implemented on DOMWindow
https://bugs.webkit.org/show_bug.cgi?id=35723
No new test. No new functionality.
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::atob):
(WebCore::JSDOMWindow::btoa):
Moved conversion code to DOMWindow and invoke it. Argument
checking remains here.
* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::V8DOMWindow::atobCallback):
(WebCore::V8DOMWindow::btoaCallback):
Remove conversion code and call DOMWindow APIs. Although argument
checking remains here.
* page/DOMWindow.cpp:
(WebCore::hasMultibyteCharacters):
(WebCore::DOMWindow::btoa):
(WebCore::DOMWindow::atob):
* page/DOMWindow.h:
Moved Conversion code from JSDOMWindow, modifing to fit JSC independent.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55619 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 8bda225..04fd08b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,19 @@
+2010-03-06 MORITA Hajime <morrita at google.com>
+
+ Reviewed by Darin Adler.
+
+ Moved implementations of window.btoa() and window.atob() from
+ JSDOMWindow to DOMWindow, and make V8DOMWindow use DOMWindow
+ functions instead of having a separate implementation. As a side effect, the
+ error message has changed from "Cannot decode base64" to one that
+ indicates DOM Exception, which is compatible to Firefox.
+
+ Refactoring: window.btoa() and window.atob() should be implemented on DOMWindow
+ https://bugs.webkit.org/show_bug.cgi?id=35723
+
+ * fast/dom/Window/atob-btoa-expected.txt:
+ Rebaselined expectation due to change of error message.
+
2010-03-06 Shu Chang <Chang.Shu at nokia.com>
Reviewed by Kenneth Rohde Christiansen.
diff --git a/LayoutTests/fast/dom/Window/atob-btoa-expected.txt b/LayoutTests/fast/dom/Window/atob-btoa-expected.txt
index 3c806d1..a2bb315 100644
--- a/LayoutTests/fast/dom/Window/atob-btoa-expected.txt
+++ b/LayoutTests/fast/dom/Window/atob-btoa-expected.txt
@@ -24,22 +24,22 @@ PASS typeof window.atob is "function"
PASS window.atob() threw exception SyntaxError: Not enough arguments.
PASS window.atob("") is ""
PASS window.atob(null) is ""
-PASS window.atob(" YQ==") threw exception Error: Cannot decode base64.
-PASS window.atob("YQ==\u000a") threw exception Error: Cannot decode base64.
+PASS window.atob(" YQ==") threw exception Error: INVALID_CHARACTER_ERR: DOM Exception 5.
+PASS window.atob("YQ==\u000a") threw exception Error: INVALID_CHARACTER_ERR: DOM Exception 5.
PASS window.atob("6ek=") is "éé"
PASS window.atob("6ek") is "éé"
PASS window.atob("gIE=") is ""
PASS window.atob("тест") threw exception Error: INVALID_CHARACTER_ERR: DOM Exception 5.
-PASS window.atob("z") threw exception Error: Cannot decode base64.
+PASS window.atob("z") threw exception Error: INVALID_CHARACTER_ERR: DOM Exception 5.
PASS window.atob("zz") is "Ï"
PASS window.atob("zzz") is "Ï<"
PASS window.atob("zzzz") is "Ï<ó"
-PASS window.atob("zzzzz") threw exception Error: Cannot decode base64.
-PASS window.atob("=") threw exception Error: Cannot decode base64.
-PASS window.atob("==") threw exception Error: Cannot decode base64.
-PASS window.atob("===") threw exception Error: Cannot decode base64.
-PASS window.atob("====") threw exception Error: Cannot decode base64.
-PASS window.atob("=====") threw exception Error: Cannot decode base64.
+PASS window.atob("zzzzz") threw exception Error: INVALID_CHARACTER_ERR: DOM Exception 5.
+PASS window.atob("=") threw exception Error: INVALID_CHARACTER_ERR: DOM Exception 5.
+PASS window.atob("==") threw exception Error: INVALID_CHARACTER_ERR: DOM Exception 5.
+PASS window.atob("===") threw exception Error: INVALID_CHARACTER_ERR: DOM Exception 5.
+PASS window.atob("====") threw exception Error: INVALID_CHARACTER_ERR: DOM Exception 5.
+PASS window.atob("=====") threw exception Error: INVALID_CHARACTER_ERR: DOM Exception 5.
PASS window.atob is 0
PASS typeof window.atob is "number"
PASS successfullyParsed is true
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 87a57a3..44a8b60 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,37 @@
+2010-03-06 MORITA Hajime <morrita at google.com>
+
+ Reviewed by Darin Adler.
+
+ Moved implementations of window.btoa() and window.atob() from
+ JSDOMWindow to DOMWindow, and make V8DOMWindow use DOMWindow
+ functions instead of having a separate implementation. As a side effect, the
+ error message has changed from "Cannot decode base64" to one that
+ indicates DOM Exception, which is compatible to Firefox.
+
+ Refactoring: window.btoa() and window.atob() should be implemented on DOMWindow
+ https://bugs.webkit.org/show_bug.cgi?id=35723
+
+ No new test. No new functionality.
+
+ * bindings/js/JSDOMWindowCustom.cpp:
+ (WebCore::JSDOMWindow::atob):
+ (WebCore::JSDOMWindow::btoa):
+ Moved conversion code to DOMWindow and invoke it. Argument
+ checking remains here.
+
+ * bindings/v8/custom/V8DOMWindowCustom.cpp:
+ (WebCore::V8DOMWindow::atobCallback):
+ (WebCore::V8DOMWindow::btoaCallback):
+ Remove conversion code and call DOMWindow APIs. Although argument
+ checking remains here.
+
+ * page/DOMWindow.cpp:
+ (WebCore::hasMultibyteCharacters):
+ (WebCore::DOMWindow::btoa):
+ (WebCore::DOMWindow::atob):
+ * page/DOMWindow.h:
+ Moved Conversion code from JSDOMWindow, modifing to fit JSC independent.
+
2010-03-06 Yuta Kitamura <yutak at chromium.org>
Reviewed by Eric Seidel.
diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp
index 96528ea..e95a5f2 100644
--- a/WebCore/bindings/js/JSDOMWindowCustom.cpp
+++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp
@@ -21,7 +21,6 @@
#include "JSDOMWindowCustom.h"
#include "AtomicString.h"
-#include "Base64.h"
#include "Chrome.h"
#include "Database.h"
#include "DOMWindow.h"
@@ -945,51 +944,28 @@ JSValue JSDOMWindow::atob(ExecState* exec, const ArgList& args)
{
if (args.size() < 1)
return throwError(exec, SyntaxError, "Not enough arguments");
-
- JSValue v = args.at(0);
- if (v.isNull())
+ if (args.at(0).isNull())
return jsEmptyString(exec);
- UString s = v.toString(exec);
- if (!s.is8Bit()) {
- setDOMException(exec, INVALID_CHARACTER_ERR);
- return jsUndefined();
- }
-
- Vector<char> in(s.size());
- for (unsigned i = 0; i < s.size(); ++i)
- in[i] = static_cast<char>(s.data()[i]);
- Vector<char> out;
-
- if (!base64Decode(in, out))
- return throwError(exec, GeneralError, "Cannot decode base64");
+ ExceptionCode ec = 0;
+ String result = impl()->atob(args.at(0).toString(exec), ec);
+ setDOMException(exec, ec);
- return jsString(exec, String(out.data(), out.size()));
+ return jsString(exec, result);
}
JSValue JSDOMWindow::btoa(ExecState* exec, const ArgList& args)
{
if (args.size() < 1)
return throwError(exec, SyntaxError, "Not enough arguments");
-
- JSValue v = args.at(0);
- if (v.isNull())
+ if (args.at(0).isNull())
return jsEmptyString(exec);
- UString s = v.toString(exec);
- if (!s.is8Bit()) {
- setDOMException(exec, INVALID_CHARACTER_ERR);
- return jsUndefined();
- }
-
- Vector<char> in(s.size());
- for (unsigned i = 0; i < s.size(); ++i)
- in[i] = static_cast<char>(s.data()[i]);
- Vector<char> out;
-
- base64Encode(in, out);
+ ExceptionCode ec = 0;
+ String result = impl()->btoa(args.at(0).toString(exec), ec);
+ setDOMException(exec, ec);
- return jsString(exec, String(out.data(), out.size()));
+ return jsString(exec, result);
}
JSValue JSDOMWindow::addEventListener(ExecState* exec, const ArgList& args)
diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
index 4597a1c..c55738f 100644
--- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
@@ -31,7 +31,6 @@
#include "config.h"
#include "V8DOMWindow.h"
-#include "Base64.h"
#include "Chrome.h"
#include "Database.h"
#include "DOMTimer.h"
@@ -148,37 +147,6 @@ v8::Handle<v8::Value> WindowSetTimeoutImpl(const v8::Arguments& args, bool singl
return v8::Integer::New(id);
}
-static bool isAscii(const String& str)
-{
- for (size_t i = 0; i < str.length(); i++) {
- if (str[i] > 0xFF)
- return false;
- }
- return true;
-}
-
-static v8::Handle<v8::Value> convertBase64(const String& str, bool encode)
-{
- if (!isAscii(str)) {
- V8Proxy::setDOMException(INVALID_CHARACTER_ERR);
- return notHandledByInterceptor();
- }
-
- Vector<char> inputCharacters(str.length());
- for (size_t i = 0; i < str.length(); i++)
- inputCharacters[i] = static_cast<char>(str[i]);
- Vector<char> outputCharacters;
-
- if (encode)
- base64Encode(inputCharacters, outputCharacters);
- else {
- if (!base64Decode(inputCharacters, outputCharacters))
- return throwError("Cannot decode base64", V8Proxy::GeneralError);
- }
-
- return v8String(String(outputCharacters.data(), outputCharacters.size()));
-}
-
v8::Handle<v8::Value> V8DOMWindow::eventAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8DOMWindow::GetTemplate(), info.This());
@@ -378,38 +346,34 @@ v8::Handle<v8::Value> V8DOMWindow::atobCallback(const v8::Arguments& args)
{
INC_STATS("DOM.DOMWindow.atob()");
+ if (args.Length() < 1)
+ return throwError("Not enough arguments", V8Proxy::SyntaxError);
if (args[0]->IsNull())
return v8String("");
- String str = toWebCoreString(args[0]);
DOMWindow* imp = V8DOMWindow::toNative(args.Holder());
+ ExceptionCode ec = 0;
+ String result = imp->atob(toWebCoreString(args[0]), ec);
+ throwError(ec);
- if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), true))
- return v8::Undefined();
-
- if (args.Length() < 1)
- return throwError("Not enough arguments", V8Proxy::SyntaxError);
-
- return convertBase64(str, false);
+ return v8String(result);
}
v8::Handle<v8::Value> V8DOMWindow::btoaCallback(const v8::Arguments& args)
{
INC_STATS("DOM.DOMWindow.btoa()");
+ if (args.Length() < 1)
+ return throwError("Not enough arguments", V8Proxy::SyntaxError);
if (args[0]->IsNull())
return v8String("");
- String str = toWebCoreString(args[0]);
DOMWindow* imp = V8DOMWindow::toNative(args.Holder());
+ ExceptionCode ec = 0;
+ String result = imp->btoa(toWebCoreString(args[0]), ec);
+ throwError(ec);
- if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), true))
- return v8::Undefined();
-
- if (args.Length() < 1)
- return throwError("Not enough arguments", V8Proxy::SyntaxError);
-
- return convertBase64(str, true);
+ return v8String(result);
}
// FIXME(fqian): returning string is cheating, and we should
diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp
index 8e1574c..ff4d8f3 100644
--- a/WebCore/page/DOMWindow.cpp
+++ b/WebCore/page/DOMWindow.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "DOMWindow.h"
+#include "Base64.h"
#include "BarInfo.h"
#include "BeforeUnloadEvent.h"
#include "CSSComputedStyleDeclaration.h"
@@ -827,6 +828,51 @@ String DOMWindow::prompt(const String& message, const String& defaultValue)
return String();
}
+static bool isSafeToConvertCharList(const String& string)
+{
+ for (unsigned i = 0; i < string.length(); i++) {
+ if (string[i] > 0xFF)
+ return false;
+ }
+
+ return true;
+}
+
+String DOMWindow::btoa(const String& stringToEncode, ExceptionCode& ec)
+{
+ if (!isSafeToConvertCharList(stringToEncode)) {
+ ec = INVALID_CHARACTER_ERR;
+ return String();
+ }
+
+ Vector<char> in;
+ in.append(stringToEncode.characters(), stringToEncode.length());
+ Vector<char> out;
+
+ base64Encode(in, out);
+
+ return String(out.data(), out.size());
+}
+
+String DOMWindow::atob(const String& encodedString, ExceptionCode& ec)
+{
+ if (!isSafeToConvertCharList(encodedString)) {
+ ec = INVALID_CHARACTER_ERR;
+ return String();
+ }
+
+ Vector<char> in;
+ in.append(encodedString.characters(), encodedString.length());
+ Vector<char> out;
+
+ if (!base64Decode(in, out)) {
+ ec = INVALID_CHARACTER_ERR;
+ return String();
+ }
+
+ return String(out.data(), out.size());
+}
+
bool DOMWindow::find(const String& string, bool caseSensitive, bool backwards, bool wrap, bool /*wholeWord*/, bool /*searchInFrames*/, bool /*showDialog*/) const
{
if (!m_frame)
diff --git a/WebCore/page/DOMWindow.h b/WebCore/page/DOMWindow.h
index fb55855..5204bf2 100644
--- a/WebCore/page/DOMWindow.h
+++ b/WebCore/page/DOMWindow.h
@@ -140,6 +140,8 @@ namespace WebCore {
void alert(const String& message);
bool confirm(const String& message);
String prompt(const String& message, const String& defaultValue);
+ String btoa(const String& stringToEncode, ExceptionCode&);
+ String atob(const String& encodedString, ExceptionCode&);
bool find(const String&, bool caseSensitive, bool backwards, bool wrap, bool wholeWord, bool searchInFrames, bool showDialog) const;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list