atob() / btoa() API should be exposed to workers
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jun 2016 01:42:05 +0000 (01:42 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jun 2016 01:42:05 +0000 (01:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158576
<rdar://problem/26729340>

Reviewed by Sam Weinig.

Source/WebCore:

Expose atob() / btoa() API to workers as per:
https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope

This aligns our behavior with Firefox and Chrome as well.

Test: fast/workers/atob-btoa.html

* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* PlatformMac.cmake:
* WebCore.xcodeproj/project.pbxproj:
* page/Base64Utilities.cpp: Added.
(WebCore::Base64Utilities::btoa):
(WebCore::Base64Utilities::atob):
* page/Base64Utilities.h: Added.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::find): Deleted.
(WebCore::DOMWindow::offscreenBuffering): Deleted.
(WebCore::DOMWindow::outerHeight): Deleted.
(WebCore::DOMWindow::outerWidth): Deleted.
* page/DOMWindow.h:
* page/DOMWindow.idl:
* page/WindowBase64.idl: Removed.
* page/WindowOrWorkerGlobalScope.idl: Renamed from Source/WebCore/page/WindowTimers.idl.
* workers/WorkerGlobalScope.h:
* workers/WorkerGlobalScope.idl:

LayoutTests:

Add test for atob() / btoa() in workers.

* fast/workers/atob-btoa-expected.txt: Added.
* fast/workers/atob-btoa.html: Added.
* fast/workers/resources/worker-atob-btoa.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201898 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/workers/atob-btoa-expected.txt [new file with mode: 0644]
LayoutTests/fast/workers/atob-btoa.html [new file with mode: 0644]
LayoutTests/fast/workers/resources/worker-atob-btoa.js [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.cpp
Source/WebCore/DerivedSources.make
Source/WebCore/PlatformMac.cmake
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/page/Base64Utilities.cpp [new file with mode: 0644]
Source/WebCore/page/Base64Utilities.h [new file with mode: 0644]
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/DOMWindow.h
Source/WebCore/page/DOMWindow.idl
Source/WebCore/page/WindowBase64.idl [deleted file]
Source/WebCore/page/WindowOrWorkerGlobalScope.idl [moved from Source/WebCore/page/WindowTimers.idl with 86% similarity]
Source/WebCore/workers/WorkerGlobalScope.h
Source/WebCore/workers/WorkerGlobalScope.idl

index e70d6a0..d136fd5 100644 (file)
@@ -1,3 +1,17 @@
+2016-06-09  Chris Dumez  <cdumez@apple.com>
+
+        atob() / btoa() API should be exposed to workers
+        https://bugs.webkit.org/show_bug.cgi?id=158576
+        <rdar://problem/26729340>
+
+        Reviewed by Sam Weinig.
+
+        Add test for atob() / btoa() in workers.
+
+        * fast/workers/atob-btoa-expected.txt: Added.
+        * fast/workers/atob-btoa.html: Added.
+        * fast/workers/resources/worker-atob-btoa.js: Added.
+
 2016-06-09  Michael Saboff  <msaboff@apple.com>
 
         ES6: Reusing function name as a parameter name shouldn't throw Syntax Error
diff --git a/LayoutTests/fast/workers/atob-btoa-expected.txt b/LayoutTests/fast/workers/atob-btoa-expected.txt
new file mode 100644 (file)
index 0000000..922474d
--- /dev/null
@@ -0,0 +1,73 @@
+[Worker] tests that atob() / btoa() work in workers.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/worker-atob-btoa.js
+PASS [Worker] self.atob("YQ==") is "a"
+PASS [Worker] self.atob("YWI=") is "ab"
+PASS [Worker] self.atob("YWJj") is "abc"
+PASS [Worker] self.atob("YWJjZA==") is "abcd"
+PASS [Worker] self.atob("YWJjZGU=") is "abcde"
+PASS [Worker] self.atob("YWJjZGVm") is "abcdef"
+PASS [Worker] self.btoa("a") is "YQ=="
+PASS [Worker] self.btoa("ab") is "YWI="
+PASS [Worker] self.btoa("abc") is "YWJj"
+PASS [Worker] self.btoa("abcd") is "YWJjZA=="
+PASS [Worker] self.btoa("abcde") is "YWJjZGU="
+PASS [Worker] self.btoa("abcdef") is "YWJjZGVm"
+PASS [Worker] typeof self.btoa is "function"
+PASS [Worker] self.btoa() threw exception TypeError: Not enough arguments.
+PASS [Worker] self.btoa("") is ""
+PASS [Worker] self.btoa(null) is "bnVsbA=="
+PASS [Worker] self.btoa(undefined) is "dW5kZWZpbmVk"
+PASS [Worker] self.btoa(self) is "W29iamVjdCBEZWRpY2F0ZWRXb3JrZXJHbG9iYWxTY29wZV0="
+PASS [Worker] self.btoa("éé") is "6ek="
+PASS [Worker] self.btoa("\u0080\u0081") is "gIE="
+PASS [Worker] self.btoa("тест") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.btoa is 0
+PASS [Worker] typeof self.btoa is "number"
+PASS [Worker] typeof self.atob is "function"
+PASS [Worker] self.atob() threw exception TypeError: Not enough arguments.
+PASS [Worker] self.atob("") is ""
+PASS [Worker] self.atob(null) is "\9eée"
+PASS [Worker] self.atob(undefined) threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob(" YQ==") is "a"
+PASS [Worker] self.atob("YQ==\u000a") is "a"
+PASS [Worker] self.atob("ab\tcd") is "i·\1d"
+PASS [Worker] self.atob("ab\ncd") is "i·\1d"
+PASS [Worker] self.atob("ab\fcd") is "i·\1d"
+PASS [Worker] self.atob("ab cd") is "i·\1d"
+PASS [Worker] self.atob("ab\t\n\f\r cd") is "i·\1d"
+PASS [Worker] self.atob(" \t\n\f\r ab\t\n\f\r cd\t\n\f\r ") is "i·\1d"
+PASS [Worker] self.atob("ab\t\n\f\r =\t\n\f\r =\t\n\f\r ") is "i"
+PASS [Worker] self.atob("            ") is ""
+PASS [Worker] self.atob(" abcd===") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob("abcd=== ") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob("abcd ===") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob("6ek=") is "éé"
+PASS [Worker] self.atob("6ek") is "éé"
+PASS [Worker] self.atob("gIE=") is "\80\81"
+PASS [Worker] self.atob("тест") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob("z") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob("zz") is "Ï"
+PASS [Worker] self.atob("zzz") is "Ï<"
+PASS [Worker] self.atob("zzz=") is "Ï<"
+PASS [Worker] self.atob("zzz==") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob("zzz===") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob("zzz====") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob("zzz=====") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob("zzzz") is "Ï<ó"
+PASS [Worker] self.atob("zzzzz") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob("z=zz") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob("=") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob("==") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob("===") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob("====") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob("=====") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS [Worker] self.atob is 0
+PASS [Worker] typeof self.atob is "number"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/workers/atob-btoa.html b/LayoutTests/fast/workers/atob-btoa.html
new file mode 100644 (file)
index 0000000..70c2103
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+worker = startWorker('resources/worker-atob-btoa.js');
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/workers/resources/worker-atob-btoa.js b/LayoutTests/fast/workers/resources/worker-atob-btoa.js
new file mode 100644 (file)
index 0000000..637d5a2
--- /dev/null
@@ -0,0 +1,77 @@
+importScripts('../../../resources/js-test-pre.js');
+
+var global = this;
+global.jsTestIsAsync = true;
+
+description("tests that atob() / btoa() work in workers.");
+
+shouldBe('self.atob("YQ==")', '"a"');
+shouldBe('self.atob("YWI=")', '"ab"');
+shouldBe('self.atob("YWJj")', '"abc"');
+shouldBe('self.atob("YWJjZA==")', '"abcd"');
+shouldBe('self.atob("YWJjZGU=")', '"abcde"');
+shouldBe('self.atob("YWJjZGVm")', '"abcdef"');
+shouldBe('self.btoa("a")', '"YQ=="');
+shouldBe('self.btoa("ab")', '"YWI="');
+shouldBe('self.btoa("abc")', '"YWJj"');
+shouldBe('self.btoa("abcd")', '"YWJjZA=="');
+shouldBe('self.btoa("abcde")', '"YWJjZGU="');
+shouldBe('self.btoa("abcdef")', '"YWJjZGVm"');
+
+shouldBe('typeof self.btoa', '"function"');
+shouldThrow('self.btoa()', '"TypeError: Not enough arguments"');
+shouldBe('self.btoa("")', '""');
+shouldBe('self.btoa(null)', '"bnVsbA=="'); // Gets converted to "null" string.
+shouldBe('self.btoa(undefined)', '"dW5kZWZpbmVk"');
+shouldBe('self.btoa(self)', '"W29iamVjdCBEZWRpY2F0ZWRXb3JrZXJHbG9iYWxTY29wZV0="'); // "[object DedicatedWorkerGlobalScope]"
+shouldBe('self.btoa("éé")', '"6ek="');
+shouldBe('self.btoa("\\u0080\\u0081")', '"gIE="');
+shouldThrow('self.btoa("тест")');
+self.btoa = 0;
+shouldBe('self.btoa', '0');
+shouldBe('typeof self.btoa', '"number"');
+
+shouldBe('typeof self.atob', '"function"');
+shouldThrow('self.atob()', '"TypeError: Not enough arguments"');
+shouldBe('self.atob("")', '""');
+shouldBe('self.atob(null)', '"\x9Eée"'); // Gets converted to "null" string.
+shouldThrow('self.atob(undefined)');
+shouldBe('self.atob(" YQ==")', '"a"');
+shouldBe('self.atob("YQ==\\u000a")', '"a"');
+shouldBe('self.atob("ab\\tcd")', '"i·\x1d"');
+shouldBe('self.atob("ab\\ncd")', '"i·\x1d"');
+shouldBe('self.atob("ab\\fcd")', '"i·\x1d"');
+shouldBe('self.atob("ab cd")', '"i·\x1d"');
+shouldBe('self.atob("ab\\t\\n\\f\\r cd")', '"i·\x1d"');
+shouldBe('self.atob(" \\t\\n\\f\\r ab\\t\\n\\f\\r cd\\t\\n\\f\\r ")', '"i·\x1d"');
+shouldBe('self.atob("ab\\t\\n\\f\\r =\\t\\n\\f\\r =\\t\\n\\f\\r ")', '"i"');
+shouldBe('self.atob("            ")', '""');
+shouldThrow('self.atob(" abcd===")');
+shouldThrow('self.atob("abcd=== ")');
+shouldThrow('self.atob("abcd ===")');
+shouldBe('self.atob("6ek=")', '"éé"');
+shouldBe('self.atob("6ek")', '"éé"');
+shouldBe('self.atob("gIE=")', '"\u0080\u0081"');
+shouldThrow('self.atob("тест")');
+shouldThrow('self.atob("z")');
+shouldBe('self.atob("zz")', '"Ï"');
+shouldBe('self.atob("zzz")', '"Ï\u003C"');
+shouldBe('self.atob("zzz=")', '"Ï\u003C"');
+shouldThrow('self.atob("zzz==")'); // excess pad characters.
+shouldThrow('self.atob("zzz===")'); // excess pad characters.
+shouldThrow('self.atob("zzz====")'); // excess pad characters.
+shouldThrow('self.atob("zzz=====")'); // excess pad characters.
+shouldBe('self.atob("zzzz")', '"Ï\u003Có"');
+shouldThrow('self.atob("zzzzz")');
+shouldThrow('self.atob("z=zz")');
+shouldThrow('self.atob("=")');
+shouldThrow('self.atob("==")');
+shouldThrow('self.atob("===")');
+shouldThrow('self.atob("====")');
+shouldThrow('self.atob("=====")');
+self.atob = 0;
+shouldBe('self.atob', '0');
+shouldBe('typeof self.atob', '"number"');
+
+finishJSTest();
+
index ebcbc14..672c4b2 100644 (file)
@@ -616,9 +616,8 @@ set(WebCore_NON_SVG_IDL_FILES
     page/UserMessageHandlersNamespace.idl
     page/WebKitNamespace.idl
     page/WebKitPoint.idl
-    page/WindowBase64.idl
     page/WindowEventHandlers.idl
-    page/WindowTimers.idl
+    page/WindowOrWorkerGlobalScope.idl
     page/WorkerNavigator.idl
 
     plugins/DOMMimeType.idl
@@ -1988,6 +1987,7 @@ set(WebCore_SOURCES
 
     page/AutoscrollController.cpp
     page/BarProp.cpp
+    page/Base64Utilities.cpp
     page/CaptionUserPreferences.cpp
     page/Chrome.cpp
     page/ContextMenuContext.cpp
index 7c8d9c4..d157ac5 100644 (file)
@@ -1,3 +1,39 @@
+2016-06-09  Chris Dumez  <cdumez@apple.com>
+
+        atob() / btoa() API should be exposed to workers
+        https://bugs.webkit.org/show_bug.cgi?id=158576
+        <rdar://problem/26729340>
+
+        Reviewed by Sam Weinig.
+
+        Expose atob() / btoa() API to workers as per:
+        https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope
+
+        This aligns our behavior with Firefox and Chrome as well.
+
+        Test: fast/workers/atob-btoa.html
+
+        * CMakeLists.txt:
+        * DerivedSources.cpp:
+        * DerivedSources.make:
+        * PlatformMac.cmake:
+        * WebCore.xcodeproj/project.pbxproj:
+        * page/Base64Utilities.cpp: Added.
+        (WebCore::Base64Utilities::btoa):
+        (WebCore::Base64Utilities::atob):
+        * page/Base64Utilities.h: Added.
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::find): Deleted.
+        (WebCore::DOMWindow::offscreenBuffering): Deleted.
+        (WebCore::DOMWindow::outerHeight): Deleted.
+        (WebCore::DOMWindow::outerWidth): Deleted.
+        * page/DOMWindow.h:
+        * page/DOMWindow.idl:
+        * page/WindowBase64.idl: Removed.
+        * page/WindowOrWorkerGlobalScope.idl: Renamed from Source/WebCore/page/WindowTimers.idl.
+        * workers/WorkerGlobalScope.h:
+        * workers/WorkerGlobalScope.idl:
+
 2016-06-09  John Wilander  <wilander@apple.com>
 
         Restrict HTTP/0.9 responses to default ports and cancel HTTP/0.9 resource loads if the document was loaded with another HTTP protocol
index cb63c0d..329a1e6 100644 (file)
 #include "JSWebKitTransitionEvent.cpp"
 #include "JSWebSocket.cpp"
 #include "JSWheelEvent.cpp"
-#include "JSWindowBase64.cpp"
 #include "JSWindowEventHandlers.cpp"
-#include "JSWindowTimers.cpp"
+#include "JSWindowOrWorkerGlobalScope.cpp"
 #include "JSWorker.cpp"
 #include "JSWorkerGlobalScope.cpp"
 #include "JSWorkerGlobalScopeFetch.cpp"
index 287126c..3b4a433 100644 (file)
@@ -525,10 +525,9 @@ NON_SVG_BINDING_IDLS = \
     $(WebCore)/page/WebKitNamespace.idl \
     $(WebCore)/page/UserMessageHandlersNamespace.idl \
     $(WebCore)/page/UserMessageHandler.idl \
-    $(WebCore)/page/WindowBase64.idl \
     $(WebCore)/page/WindowEventHandlers.idl \
-    $(WebCore)/page/WindowTimers.idl \
     $(WebCore)/page/WorkerNavigator.idl \
+    $(WebCore)/page/WindowOrWorkerGlobalScope.idl \
     $(WebCore)/plugins/DOMMimeType.idl \
     $(WebCore)/plugins/DOMMimeTypeArray.idl \
     $(WebCore)/plugins/DOMPlugin.idl \
index 9cce7cc..1462367 100644 (file)
@@ -904,9 +904,8 @@ set(ObjC_BINDINGS_NO_MM
     NonElementParentNode
     ParentNode
     URLUtils
-    WindowBase64
     WindowEventHandlers
-    WindowTimers
+    WindowOrWorkerGlobalScope
     WorkerGlobalScopeIndexedDatabase
     WorkerGlobalScopeNotifications
     XPathNSResolver
index 8760083..b49a83c 100644 (file)
                439046E712DA25E800AF80A2 /* RenderMathMLScripts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 439046D312DA25E800AF80A2 /* RenderMathMLScripts.cpp */; };
                439046E812DA25E800AF80A2 /* RenderMathMLScripts.h in Headers */ = {isa = PBXBuildFile; fileRef = 439046D412DA25E800AF80A2 /* RenderMathMLScripts.h */; };
                439046E912DA25E800AF80A2 /* RenderMathMLUnderOver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 439046D512DA25E800AF80A2 /* RenderMathMLUnderOver.cpp */; };
-               439046EA12DA25E800AF80A2 /* RenderMathMLUnderOver.h in Headers */ = {isa = PBXBuildFile; fileRef = 439046D612DA25E800AF80A2 /* RenderMathMLUnderOver.h */; };
                439046E912DA25E812AF80AC /* MathOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 439046D512DA25E812AF80AC /* MathOperator.cpp */; };
+               439046EA12DA25E800AF80A2 /* RenderMathMLUnderOver.h in Headers */ = {isa = PBXBuildFile; fileRef = 439046D612DA25E800AF80A2 /* RenderMathMLUnderOver.h */; };
                439046EA12DA25E812AF80AC /* MathOperator.h in Headers */ = {isa = PBXBuildFile; fileRef = 439046D612DA25E812AF80AC /* MathOperator.h */; };
                439046EB12DA25E800AF80A9 /* RenderMathMLToken.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 439046D712DA25E800AF80A9 /* RenderMathMLToken.cpp */; };
                439046EC12DA25E800AF80A9 /* RenderMathMLToken.h in Headers */ = {isa = PBXBuildFile; fileRef = 439046D812DA25E800AF80A9 /* RenderMathMLToken.h */; };
                458FE40A1589DF0B005609E6 /* RenderSearchField.h in Headers */ = {isa = PBXBuildFile; fileRef = 458FE4081589DF0B005609E6 /* RenderSearchField.h */; };
                45FEA5CF156DDE8C00654101 /* Decimal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 45FEA5CD156DDE8C00654101 /* Decimal.cpp */; };
                45FEA5D0156DDE8C00654101 /* Decimal.h in Headers */ = {isa = PBXBuildFile; fileRef = 45FEA5CE156DDE8C00654101 /* Decimal.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               460BB6151D0A1BF000221812 /* Base64Utilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 460BB6131D0A1BEC00221812 /* Base64Utilities.cpp */; };
+               460BB6161D0A1BF000221812 /* Base64Utilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 460BB6141D0A1BEC00221812 /* Base64Utilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4634592C1AC2271000ECB71C /* PowerObserverMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4634592B1AC2271000ECB71C /* PowerObserverMac.cpp */; };
                463EB6221B8789E00096ED51 /* TagCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 463EB6201B8789CB0096ED51 /* TagCollection.cpp */; };
                463EB6231B8789E00096ED51 /* TagCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 463EB6211B8789CB0096ED51 /* TagCollection.h */; };
                439046D312DA25E800AF80A2 /* RenderMathMLScripts.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLScripts.cpp; sourceTree = "<group>"; };
                439046D412DA25E800AF80A2 /* RenderMathMLScripts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLScripts.h; sourceTree = "<group>"; };
                439046D512DA25E800AF80A2 /* RenderMathMLUnderOver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLUnderOver.cpp; sourceTree = "<group>"; };
-               439046D612DA25E800AF80A2 /* RenderMathMLUnderOver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLUnderOver.h; sourceTree = "<group>"; };
                439046D512DA25E812AF80AC /* MathOperator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathOperator.cpp; sourceTree = "<group>"; };
+               439046D612DA25E800AF80A2 /* RenderMathMLUnderOver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLUnderOver.h; sourceTree = "<group>"; };
                439046D612DA25E812AF80AC /* MathOperator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathOperator.h; sourceTree = "<group>"; };
                439046D712DA25E800AF80A9 /* RenderMathMLToken.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLToken.cpp; sourceTree = "<group>"; };
                439046D812DA25E800AF80A9 /* RenderMathMLToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLToken.h; sourceTree = "<group>"; };
                458FE4081589DF0B005609E6 /* RenderSearchField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSearchField.h; sourceTree = "<group>"; };
                45FEA5CD156DDE8C00654101 /* Decimal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Decimal.cpp; sourceTree = "<group>"; };
                45FEA5CE156DDE8C00654101 /* Decimal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Decimal.h; sourceTree = "<group>"; };
+               460BB6131D0A1BEC00221812 /* Base64Utilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Base64Utilities.cpp; sourceTree = "<group>"; };
+               460BB6141D0A1BEC00221812 /* Base64Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base64Utilities.h; sourceTree = "<group>"; };
                4634592B1AC2271000ECB71C /* PowerObserverMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PowerObserverMac.cpp; sourceTree = "<group>"; };
                463EB6201B8789CB0096ED51 /* TagCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TagCollection.cpp; sourceTree = "<group>"; };
                463EB6211B8789CB0096ED51 /* TagCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagCollection.h; sourceTree = "<group>"; };
                                BC124EE40C2641CD009E2349 /* BarProp.cpp */,
                                BC124EE50C2641CD009E2349 /* BarProp.h */,
                                BC124EE60C2641CD009E2349 /* BarProp.idl */,
+                               460BB6131D0A1BEC00221812 /* Base64Utilities.cpp */,
+                               460BB6141D0A1BEC00221812 /* Base64Utilities.h */,
                                072CA86016CB4DC3008AE131 /* CaptionUserPreferences.cpp */,
                                079D0867162F20E800DB8658 /* CaptionUserPreferences.h */,
                                079D086A162F21F900DB8658 /* CaptionUserPreferencesMediaAF.cpp */,
                                A8EA7D2D0A19385500A8EF5F /* HTMLImageElement.h in Headers */,
                                A8EA7D2B0A19385500A8EF5F /* HTMLImageLoader.h in Headers */,
                                A81369CC097374F600D74463 /* HTMLInputElement.h in Headers */,
+                               460BB6161D0A1BF000221812 /* Base64Utilities.h in Headers */,
                                97BC849B12370A4B000C6161 /* HTMLInputStream.h in Headers */,
                                93309DE6099E64920056E581 /* HTMLInterchange.h in Headers */,
                                A81369E4097374F600D74463 /* HTMLKeygenElement.h in Headers */,
                                CE7B2DB41586ABAD0098B3FA /* AlternativeTextUIController.mm in Sources */,
                                FD31603D12B0267600C1A359 /* AnalyserNode.cpp in Sources */,
                                31A795C81888BCB500382F90 /* ANGLEInstancedArrays.cpp in Sources */,
+                               460BB6151D0A1BF000221812 /* Base64Utilities.cpp in Sources */,
                                490707E61219C04300D90E51 /* ANGLEWebKitBridge.cpp in Sources */,
                                49E912AA0EFAC906009D0CAF /* Animation.cpp in Sources */,
                                316FE1110E6E1DA700BF6088 /* AnimationBase.cpp in Sources */,
diff --git a/Source/WebCore/page/Base64Utilities.cpp b/Source/WebCore/page/Base64Utilities.cpp
new file mode 100644 (file)
index 0000000..87f0c3e
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2016 Apple Inc. 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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.
+ */
+
+#include "config.h"
+#include "Base64Utilities.h"
+
+#include <wtf/text/Base64.h>
+
+namespace WebCore {
+
+String Base64Utilities::btoa(const String& stringToEncode, ExceptionCode& ec)
+{
+    if (stringToEncode.isNull())
+        return String();
+
+    if (!stringToEncode.containsOnlyLatin1()) {
+        ec = INVALID_CHARACTER_ERR;
+        return String();
+    }
+
+    return base64Encode(stringToEncode.latin1());
+}
+
+String Base64Utilities::atob(const String& encodedString, ExceptionCode& ec)
+{
+    if (encodedString.isNull())
+        return String();
+
+    if (!encodedString.containsOnlyLatin1()) {
+        ec = INVALID_CHARACTER_ERR;
+        return String();
+    }
+
+    Vector<char> out;
+    if (!base64Decode(encodedString, out, Base64ValidatePadding | Base64IgnoreSpacesAndNewLines)) {
+        ec = INVALID_CHARACTER_ERR;
+        return String();
+    }
+
+    return String(out.data(), out.size());
+}
+
+}
diff --git a/Source/WebCore/page/Base64Utilities.h b/Source/WebCore/page/Base64Utilities.h
new file mode 100644 (file)
index 0000000..7bba9b5
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2016 Apple Inc. 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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.
+ */
+
+#pragma once
+
+#include "ExceptionCode.h"
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class Base64Utilities {
+public:
+    Base64Utilities() = default;
+
+    String btoa(const String& stringToEncode, ExceptionCode&);
+    String atob(const String& encodedString, ExceptionCode&);
+};
+
+}
index ff5700c..119bd46 100644 (file)
 #include <wtf/MathExtras.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/Ref.h>
-#include <wtf/text/Base64.h>
 #include <wtf/text/WTFString.h>
 
 #if ENABLE(USER_MESSAGE_HANDLERS)
@@ -1137,38 +1136,6 @@ String DOMWindow::prompt(const String& message, const String& defaultValue)
     return String();
 }
 
-String DOMWindow::btoa(const String& stringToEncode, ExceptionCode& ec)
-{
-    if (stringToEncode.isNull())
-        return String();
-
-    if (!stringToEncode.containsOnlyLatin1()) {
-        ec = INVALID_CHARACTER_ERR;
-        return String();
-    }
-
-    return base64Encode(stringToEncode.latin1());
-}
-
-String DOMWindow::atob(const String& encodedString, ExceptionCode& ec)
-{
-    if (encodedString.isNull())
-        return String();
-
-    if (!encodedString.containsOnlyLatin1()) {
-        ec = INVALID_CHARACTER_ERR;
-        return String();
-    }
-
-    Vector<char> out;
-    if (!base64Decode(encodedString, out, Base64ValidatePadding | Base64IgnoreSpacesAndNewLines)) {
-        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 (!isCurrentlyDisplayedInFrame())
index 9b7b7f8..3c142b9 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef DOMWindow_h
 #define DOMWindow_h
 
+#include "Base64Utilities.h"
 #include "ContextDestructionObserver.h"
 #include "EventTarget.h"
 #include "FrameDestructionObserver.h"
@@ -97,6 +98,7 @@ namespace WebCore {
         , public EventTargetWithInlineData
         , public ContextDestructionObserver
         , public FrameDestructionObserver
+        , public Base64Utilities
         , public Supplementable<DOMWindow> {
     public:
         static Ref<DOMWindow> create(Document* document) { return adoptRef(*new DOMWindow(document)); }
@@ -175,8 +177,6 @@ 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;
 
index 27c4846..6a2cda3 100644 (file)
@@ -231,6 +231,5 @@ dictionary ScrollToOptions {
 };
 
 DOMWindow implements GlobalEventHandlers;
-DOMWindow implements WindowBase64;
 DOMWindow implements WindowEventHandlers;
-DOMWindow implements WindowTimers;
+DOMWindow implements WindowOrWorkerGlobalScope;
diff --git a/Source/WebCore/page/WindowBase64.idl b/Source/WebCore/page/WindowBase64.idl
deleted file mode 100644 (file)
index 35c4320..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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 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 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);
-};
similarity index 86%
rename from Source/WebCore/page/WindowTimers.idl
rename to Source/WebCore/page/WindowOrWorkerGlobalScope.idl
index 57f5b61..dbebbe2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2009, 2013, 1016 Apple Inc. All rights reserved.
  * Copyright (C) 2011 Google Inc. All rights reserved.
  * Copyright (C) 2013 Samsung Electronics. All rights reserved.
  *
 
 [
     NoInterfaceObject,
-] interface WindowTimers {
+] interface WindowOrWorkerGlobalScope {
+    // Timers.
     [Custom] long setTimeout(any handler, optional long timeout = 0);
     void clearTimeout(optional long handle = 0);
     [Custom] long setInterval(any handler, optional long timeout = 0);
     void clearInterval(optional long handle = 0);
+
+    // Base64 utility methods.
+    [RaisesException] DOMString atob(DOMString string);
+    [RaisesException] DOMString btoa(DOMString string);
 };
 
index 2fccdab..67c5ca3 100644 (file)
@@ -26,6 +26,7 @@
 
 #pragma once
 
+#include "Base64Utilities.h"
 #include "EventListener.h"
 #include "EventTarget.h"
 #include "ScriptExecutionContext.h"
@@ -57,7 +58,7 @@ namespace IDBClient {
 class IDBConnectionProxy;
 }
 
-class WorkerGlobalScope : public RefCounted<WorkerGlobalScope>, public Supplementable<WorkerGlobalScope>, public ScriptExecutionContext, public EventTargetWithInlineData {
+class WorkerGlobalScope : public RefCounted<WorkerGlobalScope>, public Supplementable<WorkerGlobalScope>, public ScriptExecutionContext, public EventTargetWithInlineData, public Base64Utilities {
 public:
     virtual ~WorkerGlobalScope();
 
index 43eaf9e..056cb3c 100644 (file)
@@ -64,4 +64,4 @@
     [Conditional=INDEXED_DATABASE_IN_WORKERS, EnabledAtRuntime=IndexedDBWorkers] attribute IDBVersionChangeEventConstructor IDBVersionChangeEvent;
 };
 
-WorkerGlobalScope implements WindowTimers;
+WorkerGlobalScope implements WindowOrWorkerGlobalScope;