.: Support for Battery Status API.
https://bugs.webkit.org/show_bug.cgi?id=62698

Enable BATTERY_STATUS for WebKit-Efl.
http://www.w3.org/TR/battery-status/

Patch by Kihong Kwon <kihong.kwon@samsung.com> on 2012-03-16
Reviewed by Adam Barth.

* Source/cmake/OptionsEfl.cmake:
* Source/cmakeconfig.h.cmake:

Source/WebCore: Support for Battery Status API
https://bugs.webkit.org/show_bug.cgi?id=62698

Battery Status API is implemented under the Navigator class.
Battery Status API has four types of events, and all events are operated based on a callback mechanism.
 : onchargingchange, onchargingtimechange, ondischargingtimechange, onlevelchange.
The battery status can be accessed using BatteryManager(navigator.webkitBattery), and battery status is controlled by BatteryController which manages instances of BatteryManager.
When battery status event is raised, BatteryController calls all registered BatteryManager's event dispatcher.
http://www.w3.org/TR/battery-status/

Patch by Kihong Kwon <kihong.kwon@samsung.com> on 2012-03-16
Reviewed by Adam Barth.

Tests: batterystatus/add-listener-from-callback.html
       batterystatus/basic-all-types-of-events.html
       batterystatus/basic-operation.html
       batterystatus/event-after-navigation.html
       batterystatus/multiple-frames.html
       batterystatus/updates.html
       batterystatus/window-property.html

* CMakeLists.txt:
* Modules/battery/BatteryClient.h: Added.
(WebCore):
(BatteryClient):
(WebCore::BatteryClient::~BatteryClient):
* Modules/battery/BatteryController.cpp: Added.
(WebCore):
(WebCore::BatteryController::BatteryController):
(WebCore::BatteryController::~BatteryController):
(WebCore::BatteryController::create):
(WebCore::BatteryController::addListener):
(WebCore::BatteryController::removeListener):
(WebCore::BatteryController::didChangeBatteryStatus):
(WebCore::BatteryController::supplementName):
(WebCore::BatteryController::isActive):
(WebCore::provideBatteryTo):
* Modules/battery/BatteryController.h: Added.
(WebCore):
(BatteryController):
(WebCore::BatteryController::client):
(WebCore::BatteryController::from):
* Modules/battery/BatteryManager.cpp: Added.
(WebCore):
(WebCore::BatteryManager::create):
(WebCore::BatteryManager::~BatteryManager):
(WebCore::BatteryManager::BatteryManager):
(WebCore::BatteryManager::charging):
(WebCore::BatteryManager::chargingTime):
(WebCore::BatteryManager::dischargingTime):
(WebCore::BatteryManager::level):
(WebCore::BatteryManager::didChangeBatteryStatus):
(WebCore::BatteryManager::suspend):
(WebCore::BatteryManager::resume):
(WebCore::BatteryManager::stop):
* Modules/battery/BatteryManager.h: Added.
(WebCore):
(BatteryManager):
(WebCore::BatteryManager::interfaceName):
(WebCore::BatteryManager::scriptExecutionContext):
(WebCore::BatteryManager::batteryControllerDestroyed):
(WebCore::BatteryManager::canSuspend):
(WebCore::BatteryManager::eventTargetData):
(WebCore::BatteryManager::ensureEventTargetData):
(WebCore::BatteryManager::refEventTarget):
(WebCore::BatteryManager::derefEventTarget):
* Modules/battery/BatteryManager.idl: Added.
* Modules/battery/BatteryStatus.cpp: Added.
(WebCore):
(WebCore::BatteryStatus::create):
(WebCore::BatteryStatus::BatteryStatus):
* Modules/battery/BatteryStatus.h: Added.
(WebCore):
(BatteryStatus):
(WebCore::BatteryStatus::charging):
(WebCore::BatteryStatus::chargingTime):
(WebCore::BatteryStatus::dischargingTime):
(WebCore::BatteryStatus::level):
* Modules/battery/NavigatorBattery.cpp: Added.
(WebCore):
(WebCore::NavigatorBattery::NavigatorBattery):
(WebCore::NavigatorBattery::~NavigatorBattery):
(WebCore::NavigatorBattery::webkitBattery):
(WebCore::NavigatorBattery::from):
(WebCore::NavigatorBattery::batteryManager):
* Modules/battery/NavigatorBattery.h: Added.
(WebCore):
(NavigatorBattery):
* Modules/battery/NavigatorBattery.idl: Added.
* dom/EventNames.h:
(WebCore):
* dom/EventTargetFactory.in:
* testing/Internals.cpp:
(WebCore::Internals::setBatteryStatus):
(WebCore):
* testing/Internals.h:
(Internals):
* testing/Internals.idl:

Source/WebKit: Support for Battery Status API
https://bugs.webkit.org/show_bug.cgi?id=62698

Add include directory and file.
http://www.w3.org/TR/battery-status/

Patch by Kihong Kwon <kihong.kwon@samsung.com> on 2012-03-16
Reviewed by Adam Barth.

* PlatformEfl.cmake:

Source/WebKit/efl: Support for Battery Status API
https://bugs.webkit.org/show_bug.cgi?id=62698

Add BatteryClientEfl class implementation for the layout tests now.
BatteryClientEfl class is not fully implemented in this patch.
(It will be completed by other patch as necessary in the Efl port.)
http://www.w3.org/TR/battery-status/

Patch by Kihong Kwon <kihong.kwon@samsung.com> on 2012-03-16
Reviewed by Adam Barth.

* WebCoreSupport/BatteryClientEfl.cpp: Added.
(WebCore):
(WebCore::BatteryClientEfl::BatteryClientEfl):
(WebCore::BatteryClientEfl::setController):
(WebCore::BatteryClientEfl::startUpdating):
(WebCore::BatteryClientEfl::stopUpdating):
(WebCore::BatteryClientEfl::batteryControllerDestroyed):
(WebCore::BatteryClientEfl::setBatteryStatus):
* WebCoreSupport/BatteryClientEfl.h: Added.
(WebCore):
(BatteryClientEfl):
(WebCore::BatteryClientEfl::~BatteryClientEfl):
* ewk/ewk_view.cpp:
(_Ewk_View_Private_Data):
(_ewk_view_priv_new):

Tools: Support for Battery Status API
https://bugs.webkit.org/show_bug.cgi?id=62698

Add include directory and file.
http://www.w3.org/TR/battery-status/

Patch by Kihong Kwon <kihong.kwon@samsung.com> on 2012-03-16
Reviewed by Adam Barth.

* Scripts/build-webkit:

LayoutTests: Support for Battery Status API.
https://bugs.webkit.org/show_bug.cgi?id=62698

Add new test cases for Battery Status API.
http://www.w3.org/TR/battery-status/

Patch by Kihong Kwon <kihong.kwon@samsung.com> on 2012-03-16
Reviewed by Adam Barth.

* batterystatus/add-listener-from-callback-expected.txt: Added.
* batterystatus/add-listener-from-callback.html: Added.
* batterystatus/basic-all-types-of-events-expected.txt: Added.
* batterystatus/basic-all-types-of-events.html: Added.
* batterystatus/basic-operation-expected.txt: Added.
* batterystatus/basic-operation.html: Added.
* batterystatus/event-after-navigation-expected.txt: Added.
* batterystatus/event-after-navigation.html: Added.
* batterystatus/multiple-frames-expected.txt: Added.
* batterystatus/multiple-frames.html: Added.
* batterystatus/resources/event-after-navigation-new.html: Added.
* batterystatus/script-tests/add-listener-from-callback.js: Added.
(checkBatteryStatus):
(firstListener):
(secondListener):
(maybeFinishTest):
* batterystatus/script-tests/basic-all-types-of-events.js: Added.
(checkBatteryStatus):
(battery):
* batterystatus/script-tests/basic-operation.js: Added.
* batterystatus/script-tests/event-after-navigation.js: Added.
* batterystatus/script-tests/multiple-frames.js: Added.
(checkBatteryStatus):
(checkChildBatteryStatus):
(mainFrameListener):
(childFrameListener):
(maybeFinishTest):
* batterystatus/script-tests/updates.js: Added.
(checkBatteryStatus):
(setBatteryStatus):
(firstListener):
(updateListener):
* batterystatus/script-tests/window-property.js: Added.
(hasOnBatteryProperty):
* batterystatus/updates-expected.txt: Added.
* batterystatus/updates.html: Added.
* batterystatus/window-property-expected.txt: Added.
* batterystatus/window-property.html: Added.
* platform/chromium/test_expectations.txt:
* platform/gtk/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
* platform/wincairo/Skipped:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@110991 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/ChangeLog b/ChangeLog
index 7387cdf..ff6e2ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2012-03-16  Kihong Kwon  <kihong.kwon@samsung.com>
+
+        Support for Battery Status API.
+        https://bugs.webkit.org/show_bug.cgi?id=62698
+
+        Enable BATTERY_STATUS for WebKit-Efl.
+        http://www.w3.org/TR/battery-status/
+
+        Reviewed by Adam Barth.
+
+        * Source/cmake/OptionsEfl.cmake:
+        * Source/cmakeconfig.h.cmake:
+
 2012-03-15  Patrick Gansterer  <paroga@webkit.org>
 
         [EFL] Make zlib a general build requirement
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index a266737..da7a3de 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,57 @@
+2012-03-16  Kihong Kwon  <kihong.kwon@samsung.com>
+
+        Support for Battery Status API.
+        https://bugs.webkit.org/show_bug.cgi?id=62698
+
+        Add new test cases for Battery Status API.
+        http://www.w3.org/TR/battery-status/
+
+        Reviewed by Adam Barth.
+
+        * batterystatus/add-listener-from-callback-expected.txt: Added.
+        * batterystatus/add-listener-from-callback.html: Added.
+        * batterystatus/basic-all-types-of-events-expected.txt: Added.
+        * batterystatus/basic-all-types-of-events.html: Added.
+        * batterystatus/basic-operation-expected.txt: Added.
+        * batterystatus/basic-operation.html: Added.
+        * batterystatus/event-after-navigation-expected.txt: Added.
+        * batterystatus/event-after-navigation.html: Added.
+        * batterystatus/multiple-frames-expected.txt: Added.
+        * batterystatus/multiple-frames.html: Added.
+        * batterystatus/resources/event-after-navigation-new.html: Added.
+        * batterystatus/script-tests/add-listener-from-callback.js: Added.
+        (checkBatteryStatus):
+        (firstListener):
+        (secondListener):
+        (maybeFinishTest):
+        * batterystatus/script-tests/basic-all-types-of-events.js: Added.
+        (checkBatteryStatus):
+        (battery):
+        * batterystatus/script-tests/basic-operation.js: Added.
+        * batterystatus/script-tests/event-after-navigation.js: Added.
+        * batterystatus/script-tests/multiple-frames.js: Added.
+        (checkBatteryStatus):
+        (checkChildBatteryStatus):
+        (mainFrameListener):
+        (childFrameListener):
+        (maybeFinishTest):
+        * batterystatus/script-tests/updates.js: Added.
+        (checkBatteryStatus):
+        (setBatteryStatus):
+        (firstListener):
+        (updateListener):
+        * batterystatus/script-tests/window-property.js: Added.
+        (hasOnBatteryProperty):
+        * batterystatus/updates-expected.txt: Added.
+        * batterystatus/updates.html: Added.
+        * batterystatus/window-property-expected.txt: Added.
+        * batterystatus/window-property.html: Added.
+        * platform/chromium/test_expectations.txt:
+        * platform/gtk/Skipped:
+        * platform/qt/Skipped:
+        * platform/win/Skipped:
+        * platform/wincairo/Skipped:
+
 2012-03-16  Hajime Morrita  <morrita@chromium.org>
 
         Unreviewed gardening, marking a failing test.
diff --git a/LayoutTests/batterystatus/add-listener-from-callback-expected.txt b/LayoutTests/batterystatus/add-listener-from-callback-expected.txt
new file mode 100644
index 0000000..8e67459
--- /dev/null
+++ b/LayoutTests/batterystatus/add-listener-from-callback-expected.txt
@@ -0,0 +1,21 @@
+Tests that adding a new event listener from a callback works as expected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS battery.charging is charging
+PASS battery.chargingTime is chargingTime
+PASS battery.dischargingTime is dischargingTime
+PASS battery.level is level
+PASS battery.charging is charging
+PASS battery.chargingTime is chargingTime
+PASS battery.dischargingTime is dischargingTime
+PASS battery.level is level
+PASS battery.charging is charging
+PASS battery.chargingTime is chargingTime
+PASS battery.dischargingTime is dischargingTime
+PASS battery.level is level
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/batterystatus/add-listener-from-callback.html b/LayoutTests/batterystatus/add-listener-from-callback.html
new file mode 100644
index 0000000..d4b2291c
--- /dev/null
+++ b/LayoutTests/batterystatus/add-listener-from-callback.html
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/add-listener-from-callback.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/batterystatus/basic-all-types-of-events-expected.txt b/LayoutTests/batterystatus/basic-all-types-of-events-expected.txt
new file mode 100644
index 0000000..71c374f
--- /dev/null
+++ b/LayoutTests/batterystatus/basic-all-types-of-events-expected.txt
@@ -0,0 +1,29 @@
+Tests the basic operation of all BatteryStatus events.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+chargingchange event is raised
+PASS battery.charging is charging
+PASS battery.chargingTime is chargingTime
+PASS battery.dischargingTime is dischargingTime
+PASS battery.level is level
+chargingtimechange event is raised
+PASS battery.charging is charging
+PASS battery.chargingTime is chargingTime
+PASS battery.dischargingTime is dischargingTime
+PASS battery.level is level
+dischargingtimechange event is raised
+PASS battery.charging is charging
+PASS battery.chargingTime is chargingTime
+PASS battery.dischargingTime is dischargingTime
+PASS battery.level is level
+levelchange event is raised
+PASS battery.charging is charging
+PASS battery.chargingTime is chargingTime
+PASS battery.dischargingTime is dischargingTime
+PASS battery.level is level
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/batterystatus/basic-all-types-of-events.html b/LayoutTests/batterystatus/basic-all-types-of-events.html
new file mode 100644
index 0000000..7fee4e0
--- /dev/null
+++ b/LayoutTests/batterystatus/basic-all-types-of-events.html
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/basic-all-types-of-events.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/batterystatus/basic-operation-expected.txt b/LayoutTests/batterystatus/basic-operation-expected.txt
new file mode 100644
index 0000000..d13c8f0
--- /dev/null
+++ b/LayoutTests/batterystatus/basic-operation-expected.txt
@@ -0,0 +1,13 @@
+Tests the basic operation of BatteryStatus.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS battery.charging is charging
+PASS battery.chargingTime is chargingTime
+PASS battery.dischargingTime is dischargingTime
+PASS battery.level is level
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/batterystatus/basic-operation.html b/LayoutTests/batterystatus/basic-operation.html
new file mode 100644
index 0000000..e2d4474
--- /dev/null
+++ b/LayoutTests/batterystatus/basic-operation.html
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/basic-operation.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/batterystatus/event-after-navigation-expected.txt b/LayoutTests/batterystatus/event-after-navigation-expected.txt
new file mode 100644
index 0000000..8e6bc39
--- /dev/null
+++ b/LayoutTests/batterystatus/event-after-navigation-expected.txt
@@ -0,0 +1,3 @@
+Tests for a crash where an event is fired after the page has been navigated away when the original page is in the page cache.
+
+SUCCESS
diff --git a/LayoutTests/batterystatus/event-after-navigation.html b/LayoutTests/batterystatus/event-after-navigation.html
new file mode 100644
index 0000000..96b0c5e
--- /dev/null
+++ b/LayoutTests/batterystatus/event-after-navigation.html
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/event-after-navigation.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/batterystatus/multiple-frames-expected.txt b/LayoutTests/batterystatus/multiple-frames-expected.txt
new file mode 100644
index 0000000..9de2cd0
--- /dev/null
+++ b/LayoutTests/batterystatus/multiple-frames-expected.txt
@@ -0,0 +1,17 @@
+Tests using BatteryStatus from multiple frames.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS battery.charging is charging
+PASS battery.chargingTime is chargingTime
+PASS battery.dischargingTime is dischargingTime
+PASS battery.level is level
+PASS battery.charging is charging
+PASS battery.chargingTime is chargingTime
+PASS battery.dischargingTime is dischargingTime
+PASS battery.level is level
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/batterystatus/multiple-frames.html b/LayoutTests/batterystatus/multiple-frames.html
new file mode 100644
index 0000000..386b0a2
--- /dev/null
+++ b/LayoutTests/batterystatus/multiple-frames.html
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/multiple-frames.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/batterystatus/resources/event-after-navigation-new.html b/LayoutTests/batterystatus/resources/event-after-navigation-new.html
new file mode 100644
index 0000000..c132b5a
--- /dev/null
+++ b/LayoutTests/batterystatus/resources/event-after-navigation-new.html
@@ -0,0 +1,13 @@
+<html>
+  <head>
+  </head>
+  <body>
+    Tests for a crash where an event is fired after the page has been navigated
+    away when the original page is in the page cache.<br><br>
+    SUCCESS
+    <script>
+        internals.setBatteryStatus(document, 'chargingchange', true, 3000, Number.POSITIVE_INFINITY, 0.5);
+        layoutTestController.notifyDone();
+    </script>
+  </body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/batterystatus/script-tests/add-listener-from-callback.js b/LayoutTests/batterystatus/script-tests/add-listener-from-callback.js
new file mode 100644
index 0000000..7376689
--- /dev/null
+++ b/LayoutTests/batterystatus/script-tests/add-listener-from-callback.js
@@ -0,0 +1,44 @@
+description('Tests that adding a new event listener from a callback works as expected.');
+
+var charging = false;
+var chargingTime = Number.POSITIVE_INFINITY;
+var dischargingTime = 6000;
+var level = 0.7;
+
+var battery = navigator.webkitBattery;
+
+function checkBatteryStatus() {
+    shouldBe('battery.charging', 'charging');
+    shouldBe('battery.chargingTime', 'chargingTime');
+    shouldBe('battery.dischargingTime', 'dischargingTime');
+    shouldBe('battery.level', 'level');
+}
+
+var firstListenerEvents = 0;
+function firstListener() {
+    checkBatteryStatus();
+    if (++firstListenerEvents == 1) {
+        battery.addEventListener('chargingchange', secondListener);
+        internals.setBatteryStatus(document, 'chargingchange', charging, chargingTime, dischargingTime, level);
+    }
+    else if (firstListenerEvents > 2)
+        testFailed('Too many events for first listener.');
+    maybeFinishTest();
+}
+
+var secondListenerEvents = 0;
+function secondListener() {
+    checkBatteryStatus();
+    if (++secondListenerEvents > 1)
+        testFailed('Too many events for second listener.');
+    maybeFinishTest();
+}
+
+function maybeFinishTest() {
+    if (firstListenerEvents == 2 && secondListenerEvents == 1)
+        finishJSTest();
+}
+
+battery.addEventListener('chargingchange', firstListener);
+internals.setBatteryStatus(document, 'chargingchange', charging, chargingTime, dischargingTime, level);
+window.jsTestIsAsync = true;
diff --git a/LayoutTests/batterystatus/script-tests/basic-all-types-of-events.js b/LayoutTests/batterystatus/script-tests/basic-all-types-of-events.js
new file mode 100644
index 0000000..a1fbe1e
--- /dev/null
+++ b/LayoutTests/batterystatus/script-tests/basic-all-types-of-events.js
@@ -0,0 +1,42 @@
+description('Tests the basic operation of all BatteryStatus events.');
+
+var charging = false;
+var chargingTime = Number.POSITIVE_INFINITY;
+var dischargingTime = 6000;
+var level = 0.7;
+
+var battery = navigator.webkitBattery;
+
+function checkBatteryStatus() {
+    shouldBe('battery.charging', 'charging');
+    shouldBe('battery.chargingTime', 'chargingTime');
+    shouldBe('battery.dischargingTime', 'dischargingTime');
+    shouldBe('battery.level', 'level');
+}
+
+battery.addEventListener('chargingchange', function() {
+    debug('chargingchange event is raised');
+    checkBatteryStatus();
+});
+
+battery.addEventListener('chargingtimechange', function() {
+    debug('chargingtimechange event is raised');
+    checkBatteryStatus();
+});
+
+battery.addEventListener('dischargingtimechange', function() {
+    debug('dischargingtimechange event is raised');
+    checkBatteryStatus();
+});
+
+battery.addEventListener('levelchange', function() {
+    debug('levelchange event is raised');
+    checkBatteryStatus();
+    finishJSTest();
+});
+
+internals.setBatteryStatus(document, 'chargingchange', charging, chargingTime, dischargingTime, level);
+internals.setBatteryStatus(document, 'chargingtimechange', charging, chargingTime, dischargingTime, level);
+internals.setBatteryStatus(document, 'dischargingtimechange', charging, chargingTime, dischargingTime, level);
+internals.setBatteryStatus(document, 'levelchange', charging, chargingTime, dischargingTime, level);
+window.jsTestIsAsync = true;
diff --git a/LayoutTests/batterystatus/script-tests/basic-operation.js b/LayoutTests/batterystatus/script-tests/basic-operation.js
new file mode 100644
index 0000000..b58f18c
--- /dev/null
+++ b/LayoutTests/batterystatus/script-tests/basic-operation.js
@@ -0,0 +1,19 @@
+description('Tests the basic operation of BatteryStatus.');
+
+var charging = false;
+var chargingTime = Number.POSITIVE_INFINITY;
+var dischargingTime = 6000;
+var level = 0.7;
+
+var battery = navigator.webkitBattery;
+
+battery.addEventListener('chargingchange', function() {
+    shouldBe('battery.charging', 'charging');
+    shouldBe('battery.chargingTime', 'chargingTime');
+    shouldBe('battery.dischargingTime', 'dischargingTime');
+    shouldBe('battery.level', 'level');
+    finishJSTest();
+});
+
+internals.setBatteryStatus(document, 'chargingchange', charging, chargingTime, dischargingTime, level);
+window.jsTestIsAsync = true;
diff --git a/LayoutTests/batterystatus/script-tests/event-after-navigation.js b/LayoutTests/batterystatus/script-tests/event-after-navigation.js
new file mode 100644
index 0000000..de7c512
--- /dev/null
+++ b/LayoutTests/batterystatus/script-tests/event-after-navigation.js
@@ -0,0 +1,13 @@
+description('Tests for a crash where an event is fired after the page has been navigated away when the original page is in the page cache.');
+
+if (window.layoutTestController)
+    layoutTestController.overridePreference('WebKitUsesPageCachePreferenceKey', 1);
+else
+    debug('This test can not be run without the LayoutTestController');
+
+document.body.onload = function() {
+    navigator.webkitBattery.addEventListener('chargingchange', function() { } );
+    window.location = "resources/event-after-navigation-new.html";
+}
+
+window.jsTestIsAsync = true;
diff --git a/LayoutTests/batterystatus/script-tests/multiple-frames.js b/LayoutTests/batterystatus/script-tests/multiple-frames.js
new file mode 100644
index 0000000..e69581a
--- /dev/null
+++ b/LayoutTests/batterystatus/script-tests/multiple-frames.js
@@ -0,0 +1,51 @@
+description('Tests using BatteryStatus from multiple frames.');
+
+var charging = false;
+var chargingTime = Number.POSITIVE_INFINITY;
+var dischargingTime = 6000;
+var level = 0.7;
+
+var battery = navigator.webkitBattery;
+
+function checkBatteryStatus() {
+    shouldBe('battery.charging', 'charging');
+    shouldBe('battery.chargingTime', 'chargingTime');
+    shouldBe('battery.dischargingTime', 'dischargingTime');
+    shouldBe('battery.level', 'level');
+}
+
+function checkChildBatteryStatus() {
+    shouldBe('battery.charging', 'charging');
+    shouldBe('battery.chargingTime', 'chargingTime');
+    shouldBe('battery.dischargingTime', 'dischargingTime');
+    shouldBe('battery.level', 'level');
+}
+
+var hasMainFrameEventFired = false;
+function mainFrameListener() {
+    hasMainFrameEventFired = true;
+    maybeFinishTest();
+}
+
+var hasChildFrameEventFired = false;
+function childFrameListener() {
+    hasChildFrameEventFired = true;
+    maybeFinishTest();
+}
+
+function maybeFinishTest() {
+    if (hasMainFrameEventFired && hasChildFrameEventFired) {
+        checkBatteryStatus();
+        checkChildBatteryStatus();
+        finishJSTest();
+    }
+}
+
+var childFrame = document.createElement('iframe');
+document.body.appendChild(childFrame);
+var childBattery = childFrame.contentWindow.navigator.webkitBattery
+childBattery.addEventListener('chargingchange', childFrameListener);
+battery.addEventListener('chargingchange', mainFrameListener);
+
+internals.setBatteryStatus(document, 'chargingchange', charging, chargingTime, dischargingTime, level);
+window.jsTestIsAsync = true;
diff --git a/LayoutTests/batterystatus/script-tests/updates.js b/LayoutTests/batterystatus/script-tests/updates.js
new file mode 100644
index 0000000..7a96667
--- /dev/null
+++ b/LayoutTests/batterystatus/script-tests/updates.js
@@ -0,0 +1,39 @@
+description('Tests that updates to the battery event causes new events to fire.');
+
+var charging = false;
+var chargingTime = Number.POSITIVE_INFINITY;
+var dischargingTime = 6000;
+var level = 0.7;
+
+var battery = navigator.webkitBattery;
+
+function checkBatteryStatus() {
+    shouldBe('battery.charging', 'charging');
+    shouldBe('battery.chargingTime', 'chargingTime');
+    shouldBe('battery.dischargingTime', 'dischargingTime');
+    shouldBe('battery.level', 'level');
+}
+
+function setBatteryStatus() {
+    internals.setBatteryStatus(document, 'chargingchange', charging, chargingTime, dischargingTime, level);
+}
+
+function firstListener() {
+    checkBatteryStatus();
+    battery.removeEventListener('chargingchange', firstListener);
+    battery.addEventListener('chargingchange', updateListener);
+    charging = true;
+    chargingTime = 7000;
+    dischargingTime = Number.POSITIVE_INFINITY;
+    level = 0.3;
+	setBatteryStatus();
+}
+
+function updateListener(event) {
+    checkBatteryStatus(event);
+    finishJSTest();
+}
+
+battery.addEventListener('chargingchange', firstListener);
+setBatteryStatus();
+window.jsTestIsAsync = true;
diff --git a/LayoutTests/batterystatus/script-tests/window-property.js b/LayoutTests/batterystatus/script-tests/window-property.js
new file mode 100644
index 0000000..fefe376
--- /dev/null
+++ b/LayoutTests/batterystatus/script-tests/window-property.js
@@ -0,0 +1,23 @@
+description('Tests that the window.navigator.battery properties are present.');
+
+function hasOnBatteryProperty()
+{
+    var result = 0;
+    for (var property in navigator.webkitBattery) {
+        if (property == 'onchargingchange' ||
+            property == 'onchargingtimechange' ||
+            property == 'ondischargingtimechange' ||
+            property == 'onlevelchange')
+            result += 1;
+    }
+    if (result == 4)
+        return true;
+    return false;
+}
+
+shouldBeTrue("typeof navigator.webkitBattery == 'object'");
+shouldBeTrue("hasOnBatteryProperty()");
+shouldBeTrue("navigator.webkitBattery.hasOwnProperty('onchargingchange')");
+shouldBeTrue("navigator.webkitBattery.hasOwnProperty('onchargingtimechange')");
+shouldBeTrue("navigator.webkitBattery.hasOwnProperty('ondischargingtimechange')");
+shouldBeTrue("navigator.webkitBattery.hasOwnProperty('onlevelchange')");
diff --git a/LayoutTests/batterystatus/updates-expected.txt b/LayoutTests/batterystatus/updates-expected.txt
new file mode 100644
index 0000000..31734c1
--- /dev/null
+++ b/LayoutTests/batterystatus/updates-expected.txt
@@ -0,0 +1,17 @@
+Tests that updates to the battery event causes new events to fire.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS battery.charging is charging
+PASS battery.chargingTime is chargingTime
+PASS battery.dischargingTime is dischargingTime
+PASS battery.level is level
+PASS battery.charging is charging
+PASS battery.chargingTime is chargingTime
+PASS battery.dischargingTime is dischargingTime
+PASS battery.level is level
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/batterystatus/updates.html b/LayoutTests/batterystatus/updates.html
new file mode 100644
index 0000000..e733ad1
--- /dev/null
+++ b/LayoutTests/batterystatus/updates.html
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/updates.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/batterystatus/window-property-expected.txt b/LayoutTests/batterystatus/window-property-expected.txt
new file mode 100644
index 0000000..41e6fd5
--- /dev/null
+++ b/LayoutTests/batterystatus/window-property-expected.txt
@@ -0,0 +1,15 @@
+Tests that the window.navigator.battery properties are present.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS typeof navigator.webkitBattery == 'object' is true
+PASS hasOnBatteryProperty() is true
+PASS navigator.webkitBattery.hasOwnProperty('onchargingchange') is true
+PASS navigator.webkitBattery.hasOwnProperty('onchargingtimechange') is true
+PASS navigator.webkitBattery.hasOwnProperty('ondischargingtimechange') is true
+PASS navigator.webkitBattery.hasOwnProperty('onlevelchange') is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/batterystatus/window-property.html b/LayoutTests/batterystatus/window-property.html
new file mode 100644
index 0000000..e9088f2
--- /dev/null
+++ b/LayoutTests/batterystatus/window-property.html
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/window-property.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/platform/chromium/test_expectations.txt b/LayoutTests/platform/chromium/test_expectations.txt
index b8db5c6..66ec743 100644
--- a/LayoutTests/platform/chromium/test_expectations.txt
+++ b/LayoutTests/platform/chromium/test_expectations.txt
@@ -113,6 +113,9 @@
 // Vibration API is not supported yet in the chromium port.
 BUGWK72010 SKIP : fast/dom/navigator-vibration.html = FAIL
 
+// Battery Status API is not supported yet in the chromium port.
+BUGWK62698 SKIP : batterystatus = PASS FAIL
+
 // -----------------------------------------------------------------
 // WONTFIX TESTS
 // -----------------------------------------------------------------
diff --git a/LayoutTests/platform/gtk/Skipped b/LayoutTests/platform/gtk/Skipped
index 0dd765e..5918f29 100644
--- a/LayoutTests/platform/gtk/Skipped
+++ b/LayoutTests/platform/gtk/Skipped
@@ -402,6 +402,9 @@
 # Pointer Lock is not implemented.
 pointer-lock/
 
+#Battery Status API support not yet. http://webkit.org/b/62698
+batterystatus
+
 ###############################################################################
 # TESTS FAILING
 ###############################################################################
diff --git a/LayoutTests/platform/mac/Skipped b/LayoutTests/platform/mac/Skipped
index eafb9a1..ebafd03 100644
--- a/LayoutTests/platform/mac/Skipped
+++ b/LayoutTests/platform/mac/Skipped
@@ -583,3 +583,7 @@
 canvas/philip/tests/2d.line.cap.round.html
 canvas/philip/tests/2d.shadow.canvas.transparent.2.html
 canvas/philip/tests/2d.shadow.image.transparent.2.html
+
+# https://bugs.webkit.org/show_bug.cgi?id=62698
+# Needs BatteryClient implementation.
+batterystatus/
diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped
index 56dd7ac..a16c4a5 100644
--- a/LayoutTests/platform/qt/Skipped
+++ b/LayoutTests/platform/qt/Skipped
@@ -362,6 +362,9 @@
 #Vibration API is not implemented.
 fast/dom/navigator-vibration.html
 
+#Battery Status API is not implemented.
+batterystatus
+
 # =========================================================================== #
 #       Drag and Drop Support in DRT.                                         #
 # =========================================================================== #
diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped
index 3cdef09..f75b6a9 100644
--- a/LayoutTests/platform/win/Skipped
+++ b/LayoutTests/platform/win/Skipped
@@ -1661,6 +1661,9 @@
 #Vibration API is not implemented.
 fast/dom/navigator-vibration.html
 
+#Battery Status API is not implemented.
+batterystatus
+
 # Those tests need a text baseline after lazily allocating layers.
 # The change should only be layer removal.
 animations/combo-transform-translate+scale.html
diff --git a/LayoutTests/platform/wincairo/Skipped b/LayoutTests/platform/wincairo/Skipped
index 1d777f4..b8c37df 100644
--- a/LayoutTests/platform/wincairo/Skipped
+++ b/LayoutTests/platform/wincairo/Skipped
@@ -2058,3 +2058,6 @@
 
 #Vibration API is not implemented.
 fast/dom/navigator-vibration.html
+
+#Battery Status API is not implemented.
+batterystatus
diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt
index bf0cd3c..69ca95a 100644
--- a/Source/WebCore/CMakeLists.txt
+++ b/Source/WebCore/CMakeLists.txt
@@ -2334,6 +2334,22 @@
     testing/InternalSettings.cpp
 )
 
+IF (ENABLE_BATTERY_STATUS)
+    LIST(APPEND WebCore_INCLUDE_DIRECTORIES
+        "${WEBCORE_DIR}/Modules/battery"
+    )
+    LIST(APPEND WebCore_IDL_FILES
+        Modules/battery/NavigatorBattery.idl
+        Modules/battery/BatteryManager.idl
+    )
+    LIST(APPEND WebCore_SOURCES
+        Modules/battery/NavigatorBattery.cpp
+        Modules/battery/BatteryController.cpp
+        Modules/battery/BatteryManager.cpp
+        Modules/battery/BatteryStatus.cpp
+    )
+ENDIF ()
+
 # Modules that the bindings generator scripts may use
 SET(SCRIPTS_RESOLVE_SUPPLEMENTAL
     ${WEBCORE_DIR}/bindings/scripts/IDLParser.pm
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 00e95e3..beebc49 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,103 @@
+2012-03-16  Kihong Kwon  <kihong.kwon@samsung.com>
+
+        Support for Battery Status API
+        https://bugs.webkit.org/show_bug.cgi?id=62698
+
+        Battery Status API is implemented under the Navigator class.
+        Battery Status API has four types of events, and all events are operated based on a callback mechanism.
+         : onchargingchange, onchargingtimechange, ondischargingtimechange, onlevelchange.
+        The battery status can be accessed using BatteryManager(navigator.webkitBattery), and battery status is controlled by BatteryController which manages instances of BatteryManager.
+        When battery status event is raised, BatteryController calls all registered BatteryManager's event dispatcher.
+        http://www.w3.org/TR/battery-status/
+
+        Reviewed by Adam Barth.
+
+        Tests: batterystatus/add-listener-from-callback.html
+               batterystatus/basic-all-types-of-events.html
+               batterystatus/basic-operation.html
+               batterystatus/event-after-navigation.html
+               batterystatus/multiple-frames.html
+               batterystatus/updates.html
+               batterystatus/window-property.html
+
+        * CMakeLists.txt:
+        * Modules/battery/BatteryClient.h: Added.
+        (WebCore):
+        (BatteryClient):
+        (WebCore::BatteryClient::~BatteryClient):
+        * Modules/battery/BatteryController.cpp: Added.
+        (WebCore):
+        (WebCore::BatteryController::BatteryController):
+        (WebCore::BatteryController::~BatteryController):
+        (WebCore::BatteryController::create):
+        (WebCore::BatteryController::addListener):
+        (WebCore::BatteryController::removeListener):
+        (WebCore::BatteryController::didChangeBatteryStatus):
+        (WebCore::BatteryController::supplementName):
+        (WebCore::BatteryController::isActive):
+        (WebCore::provideBatteryTo):
+        * Modules/battery/BatteryController.h: Added.
+        (WebCore):
+        (BatteryController):
+        (WebCore::BatteryController::client):
+        (WebCore::BatteryController::from):
+        * Modules/battery/BatteryManager.cpp: Added.
+        (WebCore):
+        (WebCore::BatteryManager::create):
+        (WebCore::BatteryManager::~BatteryManager):
+        (WebCore::BatteryManager::BatteryManager):
+        (WebCore::BatteryManager::charging):
+        (WebCore::BatteryManager::chargingTime):
+        (WebCore::BatteryManager::dischargingTime):
+        (WebCore::BatteryManager::level):
+        (WebCore::BatteryManager::didChangeBatteryStatus):
+        (WebCore::BatteryManager::suspend):
+        (WebCore::BatteryManager::resume):
+        (WebCore::BatteryManager::stop):
+        * Modules/battery/BatteryManager.h: Added.
+        (WebCore):
+        (BatteryManager):
+        (WebCore::BatteryManager::interfaceName):
+        (WebCore::BatteryManager::scriptExecutionContext):
+        (WebCore::BatteryManager::batteryControllerDestroyed):
+        (WebCore::BatteryManager::canSuspend):
+        (WebCore::BatteryManager::eventTargetData):
+        (WebCore::BatteryManager::ensureEventTargetData):
+        (WebCore::BatteryManager::refEventTarget):
+        (WebCore::BatteryManager::derefEventTarget):
+        * Modules/battery/BatteryManager.idl: Added.
+        * Modules/battery/BatteryStatus.cpp: Added.
+        (WebCore):
+        (WebCore::BatteryStatus::create):
+        (WebCore::BatteryStatus::BatteryStatus):
+        * Modules/battery/BatteryStatus.h: Added.
+        (WebCore):
+        (BatteryStatus):
+        (WebCore::BatteryStatus::charging):
+        (WebCore::BatteryStatus::chargingTime):
+        (WebCore::BatteryStatus::dischargingTime):
+        (WebCore::BatteryStatus::level):
+        * Modules/battery/NavigatorBattery.cpp: Added.
+        (WebCore):
+        (WebCore::NavigatorBattery::NavigatorBattery):
+        (WebCore::NavigatorBattery::~NavigatorBattery):
+        (WebCore::NavigatorBattery::webkitBattery):
+        (WebCore::NavigatorBattery::from):
+        (WebCore::NavigatorBattery::batteryManager):
+        * Modules/battery/NavigatorBattery.h: Added.
+        (WebCore):
+        (NavigatorBattery):
+        * Modules/battery/NavigatorBattery.idl: Added.
+        * dom/EventNames.h:
+        (WebCore):
+        * dom/EventTargetFactory.in:
+        * testing/Internals.cpp:
+        (WebCore::Internals::setBatteryStatus):
+        (WebCore):
+        * testing/Internals.h:
+        (Internals):
+        * testing/Internals.idl:
+
 2012-03-16  Ilya Tikhonovsky  <loislo@chromium.org>
 
         Web Inspector: HeapSnapshot: speedup buildReverseIndex.
diff --git a/Source/WebCore/Modules/battery/BatteryClient.h b/Source/WebCore/Modules/battery/BatteryClient.h
new file mode 100644
index 0000000..bf56336
--- /dev/null
+++ b/Source/WebCore/Modules/battery/BatteryClient.h
@@ -0,0 +1,46 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef BatteryClient_h
+#define BatteryClient_h
+
+#if ENABLE(BATTERY_STATUS)
+
+namespace WebCore {
+
+class BatteryController;
+class Page;
+
+class BatteryClient {
+public:
+    virtual ~BatteryClient() { }
+
+    virtual void setController(BatteryController*) = 0;
+    virtual void startUpdating() = 0;
+    virtual void stopUpdating() = 0;
+    virtual void batteryControllerDestroyed() = 0;
+};
+
+void provideBatteryTo(Page*, BatteryClient*);
+
+}
+
+#endif // BATTERY_STATUS
+#endif // BatteryClient_h
+
diff --git a/Source/WebCore/Modules/battery/BatteryController.cpp b/Source/WebCore/Modules/battery/BatteryController.cpp
new file mode 100644
index 0000000..5d192a9
--- /dev/null
+++ b/Source/WebCore/Modules/battery/BatteryController.cpp
@@ -0,0 +1,93 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "BatteryController.h"
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "BatteryClient.h"
+#include "BatteryStatus.h"
+#include "Event.h"
+
+namespace WebCore {
+
+BatteryController::BatteryController(BatteryClient* client)
+    : m_client(client)
+{
+    ASSERT(m_client);
+    m_client->setController(this);
+}
+
+BatteryController::~BatteryController()
+{
+    for (ListenerVector::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it)
+        (*it)->batteryControllerDestroyed();
+    m_client->batteryControllerDestroyed();
+}
+
+PassOwnPtr<BatteryController> BatteryController::create(BatteryClient* client)
+{
+    return adoptPtr(new BatteryController(client));
+}
+
+void BatteryController::addListener(BatteryManager* batteryManager)
+{
+    m_listeners.append(batteryManager);
+    m_client->startUpdating();
+}
+
+void BatteryController::removeListener(BatteryManager* batteryManager)
+{
+    size_t pos = m_listeners.find(batteryManager);
+    if (pos == WTF::notFound)
+        return;
+    m_listeners.remove(pos);
+    if (m_listeners.isEmpty())
+        m_client->stopUpdating();
+}
+
+void BatteryController::didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus> batteryStatus)
+{
+    RefPtr<Event> event = Event::create(eventType, false, false);
+    RefPtr<BatteryStatus> battery = batteryStatus;
+    for (ListenerVector::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it)
+        (*it)->didChangeBatteryStatus(event, battery);
+}
+
+const AtomicString& BatteryController::supplementName()
+{
+    DEFINE_STATIC_LOCAL(AtomicString, name, ("BatteryController"));
+    return name;
+}
+
+bool BatteryController::isActive(Page* page)
+{
+    return static_cast<bool>(BatteryController::from(page));
+}
+
+void provideBatteryTo(Page* page, BatteryClient* client)
+{
+    Supplement<Page>::provideTo(page, BatteryController::supplementName(), BatteryController::create(client));
+}
+
+}
+
+#endif // BATTERY_STATUS
+
diff --git a/Source/WebCore/Modules/battery/BatteryController.h b/Source/WebCore/Modules/battery/BatteryController.h
new file mode 100644
index 0000000..a5d779a
--- /dev/null
+++ b/Source/WebCore/Modules/battery/BatteryController.h
@@ -0,0 +1,61 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef BatteryController_h
+#define BatteryController_h
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "BatteryManager.h"
+#include "Page.h"
+
+namespace WebCore {
+
+class BatteryClient;
+
+class BatteryController : public Supplement<Page> {
+public:
+    ~BatteryController();
+
+    static PassOwnPtr<BatteryController> create(BatteryClient*);
+
+    void addListener(BatteryManager*);
+    void removeListener(BatteryManager*);
+    void didChangeBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus>);
+
+    BatteryClient* client() const { return m_client; }
+
+    static const AtomicString& supplementName();
+    static BatteryController* from(Page* page) { return static_cast<BatteryController*>(Supplement<Page>::from(page, supplementName())); }
+    static bool isActive(Page*);
+
+private:
+    typedef Vector<BatteryManager*> ListenerVector;
+
+    explicit BatteryController(BatteryClient*);
+
+    BatteryClient* m_client;
+    ListenerVector m_listeners;
+};
+
+}
+
+#endif // BATTERY_STATUS
+#endif // BatteryController_h
+
diff --git a/Source/WebCore/Modules/battery/BatteryManager.cpp b/Source/WebCore/Modules/battery/BatteryManager.cpp
new file mode 100644
index 0000000..7e8d131
--- /dev/null
+++ b/Source/WebCore/Modules/battery/BatteryManager.cpp
@@ -0,0 +1,106 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "BatteryManager.h"
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "BatteryController.h"
+#include "BatteryStatus.h"
+#include "Event.h"
+#include "Frame.h"
+#include "Navigator.h"
+#include <limits>
+
+namespace WebCore {
+
+PassRefPtr<BatteryManager> BatteryManager::create(ScriptExecutionContext* context, Navigator* navigator)
+{
+    RefPtr<BatteryManager> batteryManager(adoptRef(new BatteryManager(context, navigator)));
+    batteryManager->suspendIfNeeded();
+    return batteryManager.release();
+}
+
+BatteryManager::~BatteryManager()
+{
+}
+
+BatteryManager::BatteryManager(ScriptExecutionContext* context, Navigator* navigator)
+    : ActiveDOMObject(context, this)
+    , m_batteryController(BatteryController::from(navigator->frame()->page()))
+    , m_batteryStatus(0)
+{
+    m_batteryController->addListener(this);
+}
+
+bool BatteryManager::charging()
+{
+    return m_batteryStatus->charging();
+}
+
+double BatteryManager::chargingTime()
+{
+    if (!m_batteryStatus->charging())
+        return std::numeric_limits<double>::infinity();
+
+    return m_batteryStatus->chargingTime();
+}
+
+double BatteryManager::dischargingTime()
+{
+    if (m_batteryStatus->charging())
+        return std::numeric_limits<double>::infinity();
+
+    return m_batteryStatus->dischargingTime();
+}
+
+double BatteryManager::level()
+{
+    return m_batteryStatus->level();
+}
+
+void BatteryManager::didChangeBatteryStatus(PassRefPtr<Event> event, PassRefPtr<BatteryStatus> batteryStatus)
+{
+    m_batteryStatus = batteryStatus;
+    dispatchEvent(event);
+}
+
+void BatteryManager::suspend(ReasonForSuspension)
+{
+    if (m_batteryController)
+        m_batteryController->removeListener(this);
+}
+
+void BatteryManager::resume()
+{
+    if (m_batteryController)
+        m_batteryController->addListener(this);
+}
+
+void BatteryManager::stop()
+{
+    if (m_batteryController)
+        m_batteryController->removeListener(this);
+}
+
+} // namespace WebCore
+
+#endif // BATTERY_STATUS
+
diff --git a/Source/WebCore/Modules/battery/BatteryManager.h b/Source/WebCore/Modules/battery/BatteryManager.h
new file mode 100644
index 0000000..7978ddc
--- /dev/null
+++ b/Source/WebCore/Modules/battery/BatteryManager.h
@@ -0,0 +1,86 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef BatteryManager_h
+#define BatteryManager_h
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "ActiveDOMObject.h"
+#include "BatteryStatus.h"
+#include "EventTarget.h"
+
+namespace WebCore {
+
+class BatteryController;
+class Navigator;
+class ScriptExecutionContext;
+
+class BatteryManager : public ActiveDOMObject, public RefCounted<BatteryManager>, public EventTarget {
+public:
+    virtual ~BatteryManager();
+    static PassRefPtr<BatteryManager> create(ScriptExecutionContext*, Navigator*);
+
+    // EventTarget implementation.
+    virtual const WTF::AtomicString& interfaceName() const { return eventNames().interfaceForBatteryManager; }
+    virtual ScriptExecutionContext* scriptExecutionContext() const { return ActiveDOMObject::scriptExecutionContext(); }
+
+    bool charging();
+    double chargingTime();
+    double dischargingTime();
+    double level();
+
+    DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingchange);
+    DEFINE_ATTRIBUTE_EVENT_LISTENER(chargingtimechange);
+    DEFINE_ATTRIBUTE_EVENT_LISTENER(dischargingtimechange);
+    DEFINE_ATTRIBUTE_EVENT_LISTENER(levelchange);
+
+    void didChangeBatteryStatus(PassRefPtr<Event>, PassRefPtr<BatteryStatus>);
+    void batteryControllerDestroyed() { m_batteryController = 0; }
+
+    using RefCounted<BatteryManager>::ref;
+    using RefCounted<BatteryManager>::deref;
+
+    // ActiveDOMObject implementation.
+    virtual bool canSuspend() const { return true; }
+    virtual void suspend(ReasonForSuspension);
+    virtual void resume();
+    virtual void stop();
+
+protected:
+    virtual EventTargetData* eventTargetData() { return &m_eventTargetData; }
+    virtual EventTargetData* ensureEventTargetData() { return &m_eventTargetData; }
+
+private:
+    BatteryManager(ScriptExecutionContext*, Navigator*);
+
+    // EventTarget implementation.
+    virtual void refEventTarget() { ref(); }
+    virtual void derefEventTarget() { deref(); }
+
+    BatteryController* m_batteryController;
+    EventTargetData m_eventTargetData;
+    RefPtr<BatteryStatus> m_batteryStatus;
+};
+
+}
+
+#endif // BATTERY_STATUS
+#endif // BatteryManager_h
+
diff --git a/Source/WebCore/Modules/battery/BatteryManager.idl b/Source/WebCore/Modules/battery/BatteryManager.idl
new file mode 100644
index 0000000..e552df3
--- /dev/null
+++ b/Source/WebCore/Modules/battery/BatteryManager.idl
@@ -0,0 +1,50 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+module window {
+
+    // http://dev.w3.org/2009/dap/system-info/battery-status.html
+    interface [
+        Conditional=BATTERY_STATUS,
+        ActiveDOMObject,
+        EventTarget
+     ] BatteryManager {
+        readonly attribute boolean charging;
+        readonly attribute double chargingTime;
+        readonly attribute double dischargingTime;
+        readonly attribute double level;
+
+        attribute EventListener onchargingchange;
+        attribute EventListener onchargingtimechange;
+        attribute EventListener ondischargingtimechange;
+        attribute EventListener onlevelchange;
+
+        // EventTarget interface
+        void addEventListener(in DOMString type,
+                              in EventListener listener,
+                              in [Optional] boolean useCapture);
+        void removeEventListener(in DOMString type,
+                                 in EventListener listener,
+                                 in [Optional] boolean useCapture);
+        boolean dispatchEvent(in Event evt)
+            raises(EventException);
+    };
+
+}
+
diff --git a/Source/WebCore/Modules/battery/BatteryStatus.cpp b/Source/WebCore/Modules/battery/BatteryStatus.cpp
new file mode 100644
index 0000000..00f530b
--- /dev/null
+++ b/Source/WebCore/Modules/battery/BatteryStatus.cpp
@@ -0,0 +1,58 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "BatteryStatus.h"
+
+#if ENABLE(BATTERY_STATUS)
+
+#include <limits>
+
+namespace WebCore {
+
+PassRefPtr<BatteryStatus> BatteryStatus::create()
+{
+    return adoptRef(new BatteryStatus);
+}
+
+PassRefPtr<BatteryStatus> BatteryStatus::create(bool charging, double chargingTime, double dischargingTime, double level)
+{
+    return adoptRef(new BatteryStatus(charging, chargingTime, dischargingTime, level));
+}
+
+BatteryStatus::BatteryStatus()
+    : m_charging(true)
+    , m_chargingTime(0)
+    , m_dischargingTime(std::numeric_limits<double>::infinity())
+    , m_level(1)
+{
+}
+
+BatteryStatus::BatteryStatus(bool charging, double chargingTime, double dischargingTime, double level)
+    : m_charging(charging)
+    , m_chargingTime(chargingTime)
+    , m_dischargingTime(dischargingTime)
+    , m_level(level)
+{
+}
+
+} // namespace WebCore
+
+#endif // BATTERY_STATUS
+
diff --git a/Source/WebCore/Modules/battery/BatteryStatus.h b/Source/WebCore/Modules/battery/BatteryStatus.h
new file mode 100644
index 0000000..2c451ab
--- /dev/null
+++ b/Source/WebCore/Modules/battery/BatteryStatus.h
@@ -0,0 +1,54 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef BatteryStatus_h
+#define BatteryStatus_h
+
+#if ENABLE(BATTERY_STATUS)
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class BatteryStatus : public RefCounted<BatteryStatus> {
+public:
+    static PassRefPtr<BatteryStatus> create();
+    static PassRefPtr<BatteryStatus> create(bool charging, double chargingTime, double dischargingTime, double level);
+
+    bool charging() const { return m_charging; }
+    double chargingTime() const  { return m_chargingTime; }
+    double dischargingTime() const  { return m_dischargingTime; }
+    double level() const  { return m_level; }
+
+private:
+    BatteryStatus();
+    BatteryStatus(bool charging, double chargingTime, double dischargingTime, double level);
+
+    bool m_charging;
+    double m_chargingTime;
+    double m_dischargingTime;
+    double m_level;
+};
+
+} // namespace WebCore
+
+#endif // BATTERY_STATUS
+#endif // BatteryStatus_h
+
diff --git a/Source/WebCore/Modules/battery/NavigatorBattery.cpp b/Source/WebCore/Modules/battery/NavigatorBattery.cpp
new file mode 100644
index 0000000..1b67248
--- /dev/null
+++ b/Source/WebCore/Modules/battery/NavigatorBattery.cpp
@@ -0,0 +1,68 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "NavigatorBattery.h"
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "BatteryController.h"
+#include "BatteryManager.h"
+#include "Navigator.h"
+#include "ScriptExecutionContext.h"
+
+namespace WebCore {
+
+NavigatorBattery::NavigatorBattery()
+{
+}
+
+NavigatorBattery::~NavigatorBattery()
+{
+}
+
+BatteryManager* NavigatorBattery::webkitBattery(ScriptExecutionContext* context, Navigator* navigator)
+{
+    NavigatorBattery* navigatorBattery = NavigatorBattery::from(navigator);
+    if (!navigatorBattery->m_batteryManager)
+        navigatorBattery->m_batteryManager = BatteryManager::create(context, navigator);
+    return navigatorBattery->m_batteryManager.get();
+}
+
+NavigatorBattery* NavigatorBattery::from(Navigator* navigator)
+{
+    DEFINE_STATIC_LOCAL(AtomicString, name, ("NavigatorBattery"));
+    NavigatorBattery* supplement = static_cast<NavigatorBattery*>(Supplement<Navigator>::from(navigator, name));
+    if (!supplement) {
+        supplement = new NavigatorBattery();
+        provideTo(navigator, name, adoptPtr(supplement));
+    }
+    return supplement;
+}
+
+BatteryManager* NavigatorBattery::batteryManager()
+{
+    return m_batteryManager.get();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(BATTERY_STATUS)
+
+
diff --git a/Source/WebCore/Modules/battery/NavigatorBattery.h b/Source/WebCore/Modules/battery/NavigatorBattery.h
new file mode 100644
index 0000000..9fae9df
--- /dev/null
+++ b/Source/WebCore/Modules/battery/NavigatorBattery.h
@@ -0,0 +1,54 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef NavigatorBattery_h
+#define NavigatorBattery_h
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "Supplementable.h"
+
+namespace WebCore {
+
+class BatteryManager;
+class Navigator;
+class ScriptExecutionContext;
+
+class NavigatorBattery : public Supplement<Navigator> {
+public:
+    virtual ~NavigatorBattery();
+
+    static NavigatorBattery* from(Navigator*);
+
+    static BatteryManager* webkitBattery(ScriptExecutionContext*, Navigator*);
+    BatteryManager* batteryManager();
+
+ private:
+    NavigatorBattery();
+
+    RefPtr<BatteryManager> m_batteryManager;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(BATTERY_STATUS)
+
+#endif // NavigatorBattery_h
+
+
diff --git a/Source/WebCore/Modules/battery/NavigatorBattery.idl b/Source/WebCore/Modules/battery/NavigatorBattery.idl
new file mode 100644
index 0000000..6cdb783
--- /dev/null
+++ b/Source/WebCore/Modules/battery/NavigatorBattery.idl
@@ -0,0 +1,31 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+module window {
+
+    interface [
+        CallWith=ScriptExecutionContext,
+        Conditional=BATTERY_STATUS,
+        Supplemental=Navigator
+    ] NavigatorBattery {
+        readonly attribute BatteryManager webkitBattery;
+    };
+
+}
+
diff --git a/Source/WebCore/dom/EventNames.h b/Source/WebCore/dom/EventNames.h
index dbfc4f9c..6e22b73 100644
--- a/Source/WebCore/dom/EventNames.h
+++ b/Source/WebCore/dom/EventNames.h
@@ -41,6 +41,8 @@
     macro(blur) \
     macro(cached) \
     macro(change) \
+    macro(chargingchange) \
+    macro(chargingtimechange) \
     macro(checking) \
     macro(click) \
     macro(close) \
@@ -55,6 +57,7 @@
     macro(dblclick) \
     macro(devicemotion) \
     macro(deviceorientation) \
+    macro(dischargingtimechange) \
     macro(display) \
     macro(downloading) \
     macro(drag) \
@@ -74,6 +77,7 @@
     macro(keydown) \
     macro(keypress) \
     macro(keyup) \
+    macro(levelchange) \
     macro(load) \
     macro(loadstart) \
     macro(message) \
diff --git a/Source/WebCore/dom/EventTargetFactory.in b/Source/WebCore/dom/EventTargetFactory.in
index 8577d3e..d998b46 100644
--- a/Source/WebCore/dom/EventTargetFactory.in
+++ b/Source/WebCore/dom/EventTargetFactory.in
@@ -1,6 +1,7 @@
 namespace="EventTarget"
 
 AudioContext conditional=WEB_AUDIO
+BatteryManager conditional=BATTERY_STATUS
 DedicatedWorkerContext conditional=WORKERS
 DOMApplicationCache
 DOMWindow
diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp
index c293686..622b64e 100644
--- a/Source/WebCore/testing/Internals.cpp
+++ b/Source/WebCore/testing/Internals.cpp
@@ -67,6 +67,10 @@
 #include "ColorChooser.h"
 #endif
 
+#if ENABLE(BATTERY_STATUS)
+#include "BatteryController.h"
+#endif
+
 namespace WebCore {
 
 static bool markerTypesFrom(const String& markerType, DocumentMarker::MarkerTypes& result)
@@ -714,4 +718,22 @@
     InspectorInstrumentation::didCancelFrame(frame()->page());
 }
 
+void Internals::setBatteryStatus(Document* document, const String& eventType, bool charging, double chargingTime, double dischargingTime, double level, ExceptionCode& ec)
+{
+    if (!document || !document->page()) {
+        ec = INVALID_ACCESS_ERR;
+        return;
+    }
+
+#if ENABLE(BATTERY_STATUS)
+    BatteryController::from(document->page())->didChangeBatteryStatus(eventType, BatteryStatus::create(charging, chargingTime, dischargingTime, level));
+#else
+    UNUSED_PARAM(eventType);
+    UNUSED_PARAM(charging);
+    UNUSED_PARAM(chargingTime);
+    UNUSED_PARAM(dischargingTime);
+    UNUSED_PARAM(level);
+#endif
+}
+
 }
diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h
index 67c0922..9716a3c 100644
--- a/Source/WebCore/testing/Internals.h
+++ b/Source/WebCore/testing/Internals.h
@@ -136,6 +136,8 @@
 
     InternalSettings* settings() const { return m_settings.get(); }
 
+    void setBatteryStatus(Document*, const String& eventType, bool charging, double chargingTime, double dischargingTime, double level, ExceptionCode&);
+
 private:
     explicit Internals(Document*);
     DocumentMarker* markerAt(Node*, const String& markerType, unsigned index, ExceptionCode&);
diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl
index d9856ad..72bf907 100644
--- a/Source/WebCore/testing/Internals.idl
+++ b/Source/WebCore/testing/Internals.idl
@@ -110,6 +110,10 @@
         void emitInspectorDidCancelFrame();
 
         readonly attribute InternalSettings settings;
+
+#if defined(ENABLE_BATTERY_STATUS) && ENABLE_BATTERY_STATUS
+        void setBatteryStatus(in Document document, in DOMString eventType, in boolean charging, in double chargingTime, in double dischargingTime, in double level) raises (DOMException);
+#endif
     };
 }
 
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index 4f1cf58..bc3a567 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,15 @@
+2012-03-16  Kihong Kwon  <kihong.kwon@samsung.com>
+
+        Support for Battery Status API
+        https://bugs.webkit.org/show_bug.cgi?id=62698
+
+        Add include directory and file.
+        http://www.w3.org/TR/battery-status/
+
+        Reviewed by Adam Barth.
+
+        * PlatformEfl.cmake:
+
 2012-03-11  Timothy Hatcher  <timothy@apple.com>
 
         Update how the Web Inspector resources are loaded.
diff --git a/Source/WebKit/PlatformEfl.cmake b/Source/WebKit/PlatformEfl.cmake
index 1debe36..1584135 100644
--- a/Source/WebKit/PlatformEfl.cmake
+++ b/Source/WebKit/PlatformEfl.cmake
@@ -126,6 +126,10 @@
     )
 ENDIF ()
 
+IF (ENABLE_BATTERY_STATUS)
+    LIST(APPEND WebKit_INCLUDE_DIRECTORIES ${WEBCORE_DIR}/Modules/battery)
+    LIST(APPEND WebKit_SOURCES efl/WebCoreSupport/BatteryClientEfl.cpp)
+ENDIF ()
 
 SET(WebKit_THEME_DEFINITION "")
 IF (ENABLE_PROGRESS_TAG)
diff --git a/Source/WebKit/efl/ChangeLog b/Source/WebKit/efl/ChangeLog
index 306775a..14718db 100644
--- a/Source/WebKit/efl/ChangeLog
+++ b/Source/WebKit/efl/ChangeLog
@@ -1,3 +1,31 @@
+2012-03-16  Kihong Kwon  <kihong.kwon@samsung.com>
+
+        Support for Battery Status API
+        https://bugs.webkit.org/show_bug.cgi?id=62698
+
+        Add BatteryClientEfl class implementation for the layout tests now.
+        BatteryClientEfl class is not fully implemented in this patch.
+        (It will be completed by other patch as necessary in the Efl port.)
+        http://www.w3.org/TR/battery-status/
+
+        Reviewed by Adam Barth.
+
+        * WebCoreSupport/BatteryClientEfl.cpp: Added.
+        (WebCore):
+        (WebCore::BatteryClientEfl::BatteryClientEfl):
+        (WebCore::BatteryClientEfl::setController):
+        (WebCore::BatteryClientEfl::startUpdating):
+        (WebCore::BatteryClientEfl::stopUpdating):
+        (WebCore::BatteryClientEfl::batteryControllerDestroyed):
+        (WebCore::BatteryClientEfl::setBatteryStatus):
+        * WebCoreSupport/BatteryClientEfl.h: Added.
+        (WebCore):
+        (BatteryClientEfl):
+        (WebCore::BatteryClientEfl::~BatteryClientEfl):
+        * ewk/ewk_view.cpp:
+        (_Ewk_View_Private_Data):
+        (_ewk_view_priv_new):
+
 2012-03-13  Jon Lee  <jonlee@apple.com>
 
         Separate NOTIFICATIONS and LEGACY_NOTIFICATIONS
diff --git a/Source/WebKit/efl/WebCoreSupport/BatteryClientEfl.cpp b/Source/WebKit/efl/WebCoreSupport/BatteryClientEfl.cpp
new file mode 100644
index 0000000..88dbfd9
--- /dev/null
+++ b/Source/WebKit/efl/WebCoreSupport/BatteryClientEfl.cpp
@@ -0,0 +1,62 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "BatteryClientEfl.h"
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "BatteryController.h"
+
+namespace WebCore {
+
+BatteryClientEfl::BatteryClientEfl()
+    : m_controller(0)
+{
+}
+
+void BatteryClientEfl::setController(BatteryController* controller)
+{
+    m_controller = controller;
+}
+
+void BatteryClientEfl::startUpdating()
+{
+    // FIXME: Need to implement for getting battery status to the efl port.
+}
+
+void BatteryClientEfl::stopUpdating()
+{
+    // FIXME: Need to implement for getting battery status to the efl port
+}
+
+void BatteryClientEfl::batteryControllerDestroyed()
+{
+    delete this;
+}
+
+void BatteryClientEfl::setBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus> batteryStatus)
+{
+    m_controller->didChangeBatteryStatus(eventType, batteryStatus);
+}
+
+}
+
+#endif // BATTERY_STATUS
+
diff --git a/Source/WebKit/efl/WebCoreSupport/BatteryClientEfl.h b/Source/WebKit/efl/WebCoreSupport/BatteryClientEfl.h
new file mode 100644
index 0000000..a4f71c8
--- /dev/null
+++ b/Source/WebKit/efl/WebCoreSupport/BatteryClientEfl.h
@@ -0,0 +1,53 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef BatteryClientEfl_h
+#define BatteryClientEfl_h
+
+#if ENABLE(BATTERY_STATUS)
+
+#include "BatteryClient.h"
+#include <wtf/text/AtomicString.h>
+
+namespace WebCore {
+
+class BatteryController;
+class BatteryStatus;
+
+class BatteryClientEfl : public BatteryClient {
+public:
+    BatteryClientEfl();
+    ~BatteryClientEfl() { };
+
+    virtual void setController(BatteryController*);
+    virtual void startUpdating();
+    virtual void stopUpdating();
+    virtual void batteryControllerDestroyed();
+
+    void setBatteryStatus(const AtomicString& eventType, PassRefPtr<BatteryStatus>);
+
+private:
+    BatteryController* m_controller;
+};
+
+}
+
+#endif // BATTERY_STATUS
+#endif // BatteryClientEfl_h
+
diff --git a/Source/WebKit/efl/ewk/ewk_view.cpp b/Source/WebKit/efl/ewk/ewk_view.cpp
index 17a6ea0..7a52caf 100644
--- a/Source/WebKit/efl/ewk/ewk_view.cpp
+++ b/Source/WebKit/efl/ewk/ewk_view.cpp
@@ -74,6 +74,10 @@
 #include "VibrationClientEfl.h"
 #endif
 
+#if ENABLE(BATTERY_STATUS)
+#include "BatteryClientEfl.h"
+#endif
+
 static const float zoomMinimum = 0.05;
 static const float zoomMaximum = 4.0;
 
@@ -618,6 +622,10 @@
     WebCore::provideVibrationTo(priv->page.get(), new WebCore::VibrationClientEfl(smartData->self));
 #endif
 
+#if ENABLE(BATTERY_STATUS)
+    WebCore::provideBatteryTo(priv->page.get(), new WebCore::BatteryClientEfl);
+#endif
+
     priv->pageSettings = priv->page->settings();
 
     priv->viewportArguments.width = WebCore::ViewportArguments::ValueAuto;
diff --git a/Source/cmake/OptionsEfl.cmake b/Source/cmake/OptionsEfl.cmake
index 40e8730..41f50eb 100644
--- a/Source/cmake/OptionsEfl.cmake
+++ b/Source/cmake/OptionsEfl.cmake
@@ -64,6 +64,7 @@
 
 SET(VERSION_SCRIPT "-Wl,--version-script,${CMAKE_MODULE_PATH}/eflsymbols.filter")
 
+WEBKIT_FEATURE(ENABLE_BATTERY_STATUS "Enable battery status api" DEFAULT ON)
 WEBKIT_FEATURE(ENABLE_BLOB "Enable blob slice" DEFAULT OFF)
 WEBKIT_FEATURE(ENABLE_CHANNEL_MESSAGING "Enable channel messaging" DEFAULT ON)
 WEBKIT_FEATURE(ENABLE_DATALIST "Enable datalist" DEFAULT ON)
diff --git a/Source/cmakeconfig.h.cmake b/Source/cmakeconfig.h.cmake
index ce216ab..82caf6f 100644
--- a/Source/cmakeconfig.h.cmake
+++ b/Source/cmakeconfig.h.cmake
@@ -6,6 +6,7 @@
 
 
 #cmakedefine01 ENABLE_AS_IMAGE
+#cmakedefine01 ENABLE_BATTERY_STATUS
 #cmakedefine01 ENABLE_BLOB
 #cmakedefine01 ENABLE_CHANNEL_MESSAGING
 #cmakedefine01 ENABLE_DATALIST
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index e422cb5..aa260cc 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,15 @@
+2012-03-16  Kihong Kwon  <kihong.kwon@samsung.com>
+
+        Support for Battery Status API
+        https://bugs.webkit.org/show_bug.cgi?id=62698
+
+        Add include directory and file.
+        http://www.w3.org/TR/battery-status/
+
+        Reviewed by Adam Barth.
+
+        * Scripts/build-webkit:
+
 2012-03-16  Kishore Bolisetty  <kbolisetty@innominds.com>
 
         check-webkit-style fails on LayoutTests/platform/efl/test_expectations.txt
diff --git a/Tools/Scripts/build-webkit b/Tools/Scripts/build-webkit
index adffdb9..ccc4315 100755
--- a/Tools/Scripts/build-webkit
+++ b/Tools/Scripts/build-webkit
@@ -70,6 +70,7 @@
     $threeDRenderingSupport,
     $accelerated2dCanvasSupport,
     $animationAPISupport,
+    $batterystatusAPISupport,
     $blobSupport,
     $channelMessagingSupport,
     $coverageSupport,
@@ -160,6 +161,9 @@
     { option => "animation-api", desc => "Toggle animation API support",
       define => "ENABLE_ANIMATION_API", default => isBlackBerry(), value => \$animationAPISupport },
 
+    { option => "battery-status-api", desc => "Toggle battery status API support",
+      define => "ENABLE_BATTERY_STATUS", default => isEfl(), value => \$batterystatusAPISupport },
+
     { option => "blob", desc => "Toggle Blob support",
       define => "ENABLE_BLOB", default => (isAppleMacWebKit() || isGtk() || isChromium() || isBlackBerry()), value => \$blobSupport },