Commit be27cd7c authored by abarth@webkit.org's avatar abarth@webkit.org

Source/WebCore: WebCore implementation of the Intent object

See http://dvcs.w3.org/hg/web-intents/raw-file/tip/spec/Overview.html
for draft spec.

https://bugs.webkit.org/show_bug.cgi?id=73051

Patch by Greg Billock <gbillock@google.com> on 2012-01-06
Reviewed by Adam Barth.

Test: web-intents/web-intents-api.html

* WebCore.gypi:
* page/DOMWindow.idl:
* Modules/intents/Intent.cpp: Added.
(WebCore::Intent::Intent):
(WebCore::Intent::action):
(WebCore::Intent::setAction):
(WebCore::Intent::type):
(WebCore::Intent::setType):
(WebCore::Intent::data):
(WebCore::Intent::setData):
(WebCore::Intent::create):
* Modules/intents/Intent.h: Added.
* Modules/intents/Intent.idl: Added.

Source/WebKit/chromium: [Web Intents] Flagged-off WebCore implementation of navigator.startActivity
https://bugs.webkit.org/show_bug.cgi?id=73051

Patch by Greg Billock <gbillock@google.com> on 2012-01-06
Reviewed by Adam Barth.

* features.gypi:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104358 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 359441bd
......@@ -91,6 +91,10 @@ BUGWK68610 SKIP : fast/dom/MicroData = PASS
// Unskip after changes on both sides have landed and rolled together.
BUGCR103939 SKIP : http/tests/appcache/wrong-content-type.html = TEXT
// Currently Web Intents is disabled. Tests pass with the proper
// build flag turned on.
BUGGBILLOCK SKIP : webintents = FAIL
// -----------------------------------------------------------------
// WONTFIX TESTS
// -----------------------------------------------------------------
......
......@@ -1928,6 +1928,9 @@ http/tests/websocket/tests/hybi/
# Microdata DOM API is not yet enabled.
fast/dom/MicroData
# Web Intents is not yet enabled.
webintents/
# Pointer Lock is not implemented.
pointer-lock/
......
......@@ -1435,6 +1435,9 @@ fast/frames/flattening/iframe-flattening-fixed-width-and-height-no-scrolling.htm
# https://bugs.webkit.org/show_bug.cgi?id=72248
editing/spelling/spelling-unified-emulation.html
# Web Intents is not yet enabled.
webintents/
# Pointer Lock is not implemented.
pointer-lock/
......
......@@ -488,6 +488,9 @@ fast/repaint/table-extra-bottom-grow.html
# DRT doesn't support overridePreference("WebKit*FontMap"...)
fast/text/international/locale-sensitive-fonts.html
# Web Intents is not yet enabled.
webintents/
# Pointer Lock is not implemented.
pointer-lock/
......
......@@ -2484,6 +2484,9 @@ css3/flexbox/line-wrapping.html
# https://bugs.webkit.org/show_bug.cgi?id=72491
http/tests/misc/onload-remove-iframe-crash-2.html
# Web Intents is not yet enabled.
webintents/
# Pointer Lock is not implemented.
pointer-lock/
......
......@@ -1483,6 +1483,9 @@ fast/events/platform-wheelevent-paging-y-in-scrolling-page.html
# DRT doesn't support overridePreference("WebKit*FontMap"...)
fast/text/international/locale-sensitive-fonts.html
# Web Intents is not yet enabled.
webintents/
# Pointer Lock is not implemented.
pointer-lock/
......
......@@ -2021,6 +2021,9 @@ fast/events/platform-wheelevent-paging-y-in-scrolling-page.html
# DRT doesn't support overridePreference("WebKit*FontMap"...)
fast/text/international/locale-sensitive-fonts.html
# Web Intents is not yet enabled.
webintents/
# Pointer Lock is not implemented.
pointer-lock/
......
PASS var intent = new Intent() threw exception TypeError: Not enough arguments.
PASS new Intent('a') threw exception TypeError: Not enough arguments.
PASS new Intent('','','') threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS new Intent('','b','c') threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS new Intent('','','c') threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS new Intent('a','','c') threw exception Error: SYNTAX_ERR: DOM Exception 12.
PASS intent1.action is "a"
PASS intent1.type is "b"
PASS intent1.data is undefined.
PASS intent1.action is "a"
PASS intent2.action is "a"
PASS intent2.type is "b"
PASS intent2.data is "c"
PASS intent3.action is "a"
PASS intent3.type is "b"
PASS intent3.data.c is "d"
PASS intent4.action is "a"
PASS intent4.type is "b"
PASS intent4.data instanceof Array is true
PASS intent4.data.length is 2
PASS intent4.data[0] is "c"
PASS intent4.data[1] is "d"
PASS intent5.data is 4
PASS intent6.data is 4.5
PASS intent7.data is true
PASS intent8.data is null
PASS intent9.data == '[object Object]' is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<script type="text/javascript">
shouldThrow("var intent = new Intent()", "'TypeError: Not enough arguments'");;
shouldThrow("new Intent('a')", "'TypeError: Not enough arguments'");
shouldThrow("new Intent('','','')", "'Error: SYNTAX_ERR: DOM Exception 12'");
shouldThrow("new Intent('','b','c')", "'Error: SYNTAX_ERR: DOM Exception 12'");
shouldThrow("new Intent('','','c')", "'Error: SYNTAX_ERR: DOM Exception 12'");
shouldThrow("new Intent('a','','c')", "'Error: SYNTAX_ERR: DOM Exception 12'");
var intent1 = new Intent('a', 'b');
shouldBeEqualToString("intent1.action", "a");
shouldBeEqualToString("intent1.type", "b");
shouldBeUndefined("intent1.data");
intent1.action = "abc";
shouldBeEqualToString("intent1.action", "a");
var intent2 = new Intent("a", "b", "c");
shouldBeEqualToString('intent2.action', "a");
shouldBeEqualToString('intent2.type', "b");
shouldBeEqualToString('intent2.data', "c");
var intent3 = new Intent("a", "b", {"c": "d"});
shouldBeEqualToString('intent3.action', "a");
shouldBeEqualToString('intent3.type', "b");
shouldBeEqualToString('intent3.data.c', "d");
var intent4 = new Intent("a", "b", ["c", "d"]);
shouldBeEqualToString('intent4.action', "a");
shouldBeEqualToString('intent4.type', "b");
shouldBeTrue('intent4.data instanceof Array');
shouldEvaluateTo('intent4.data.length', 2);
shouldBeEqualToString('intent4.data[0]', "c");
shouldBeEqualToString('intent4.data[1]', "d");
var intent5 = new Intent("a", "b", 4);
shouldEvaluateTo('intent5.data', 4);
var intent6 = new Intent('a', 'b', 4.5);
shouldEvaluateTo('intent6.data', 4.5);
var intent7 = new Intent('a', 'b', true);
shouldBeTrue('intent7.data');
var intent8 = new Intent('a', 'b', null);
shouldBeNull('intent8.data');
var intent9 = new Intent('a', 'b', {});
shouldEvaluateTo('intent9.data', {});
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
</html>
2012-01-06 Greg Billock <gbillock@google.com>
WebCore implementation of the Intent object
See http://dvcs.w3.org/hg/web-intents/raw-file/tip/spec/Overview.html
for draft spec.
https://bugs.webkit.org/show_bug.cgi?id=73051
Reviewed by Adam Barth.
Test: web-intents/web-intents-api.html
* WebCore.gypi:
* page/DOMWindow.idl:
* Modules/intents/Intent.cpp: Added.
(WebCore::Intent::Intent):
(WebCore::Intent::action):
(WebCore::Intent::setAction):
(WebCore::Intent::type):
(WebCore::Intent::setType):
(WebCore::Intent::data):
(WebCore::Intent::setData):
(WebCore::Intent::create):
* Modules/intents/Intent.h: Added.
* Modules/intents/Intent.idl: Added.
2012-01-06 Tim Horton <timothy_horton@apple.com>
[cg] userSpaceOnUse SVG Patterns have the wrong origin
/*
* Copyright (C) 2011 Google 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.
* 3. Neither the name of Google, Inc. ("Google") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY GOOGLE 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 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 "Intent.h"
#if ENABLE(WEB_INTENTS)
#include "ExceptionCode.h"
#include "SerializedScriptValue.h"
namespace WebCore {
PassRefPtr<Intent> Intent::create(const String& action, const String& type, PassRefPtr<SerializedScriptValue> data, ExceptionCode& ec)
{
if (action.isEmpty()) {
ec = SYNTAX_ERR;
return 0;
}
if (type.isEmpty()) {
ec = SYNTAX_ERR;
return 0;
}
return adoptRef(new Intent(action, type, data));
}
Intent::Intent(const String& action, const String& type, PassRefPtr<SerializedScriptValue> data)
: m_action(action)
, m_type(type)
{
if (data)
m_data = SerializedScriptValue::createFromWire(data->toWireString());
else
m_data = SerializedScriptValue::nullValue();
}
const String& Intent::action() const
{
return m_action;
}
const String& Intent::type() const
{
return m_type;
}
SerializedScriptValue* Intent::data() const
{
return m_data.get();
}
} // namespace WebCore
#endif // ENABLE(WEB_INTENTS)
/*
* Copyright (C) 2011 Google 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.
* 3. Neither the name of Google, Inc. ("Google") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY GOOGLE 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 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.
*/
#ifndef Intent_h
#define Intent_h
#if ENABLE(WEB_INTENTS)
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class SerializedScriptValue;
typedef int ExceptionCode;
class Intent : public RefCounted<Intent> {
public:
static PassRefPtr<Intent> create(const String& action, const String& type, PassRefPtr<SerializedScriptValue> data, ExceptionCode&);
const String& action() const;
const String& type() const;
SerializedScriptValue* data() const;
int identifier() const;
void setIdentifier(int);
private:
Intent(const String& action, const String& type, PassRefPtr<SerializedScriptValue> data);
String m_action;
String m_type;
RefPtr<SerializedScriptValue> m_data;
};
} // namespace WebCore
#endif
#endif // Intent_h
/*
* Copyright (C) 2011 Google 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 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 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.
*/
module window {
interface [
Conditional=WEB_INTENTS,
Constructor(in DOMString action, in DOMString type, in [Optional=CallWithNullValue] SerializedScriptValue data),
ConstructorRaisesException
] Intent {
readonly attribute DOMString action;
readonly attribute DOMString type;
readonly attribute SerializedScriptValue data;
};
}
......@@ -51,6 +51,7 @@
'../',
'../..',
'../Modules/gamepad',
'../Modules/intents',
'../accessibility',
'../accessibility/chromium',
'../bindings',
......
......@@ -1149,6 +1149,7 @@
'Modules/gamepad/Gamepad.idl',
'Modules/gamepad/GamepadList.idl',
'Modules/gamepad/NavigatorGamepad.idl',
'Modules/intents/Intent.idl',
'css/CSSCharsetRule.idl',
'css/CSSFontFaceRule.idl',
'css/CSSImportRule.idl',
......@@ -1695,6 +1696,8 @@
'Modules/gamepad/GamepadList.h',
'Modules/gamepad/NavigatorGamepad.cpp',
'Modules/gamepad/NavigatorGamepad.h',
'Modules/intents/Intent.cpp',
'Modules/intents/Intent.h',
'accessibility/AXObjectCache.cpp',
'accessibility/AccessibilityARIAGrid.cpp',
'accessibility/AccessibilityARIAGrid.h',
......
......@@ -607,6 +607,8 @@ module window {
attribute [EnabledAtRuntime=webkitVideoTrack] TrackEventConstructor TrackEvent;
#endif
attribute [Conditional=WEB_INTENTS] IntentConstructor Intent; // Usable with the new operator
attribute DOMPluginConstructor Plugin;
attribute DOMPluginArrayConstructor PluginArray;
......
2012-01-06 Greg Billock <gbillock@google.com>
[Web Intents] Flagged-off WebCore implementation of navigator.startActivity
https://bugs.webkit.org/show_bug.cgi?id=73051
Reviewed by Adam Barth.
* features.gypi:
2012-01-06 Tom Sepez <tsepez@chromium.org>
Pass Content-security-policy directive to worker threads.
......
......@@ -159,6 +159,11 @@
'ENABLE_REGISTER_PROTOCOL_HANDLER=1',
],
}],
['enable_web_intents==1', {
'feature_defines': [
'ENABLE_WEB_INTENTS=1',
],
}],
['OS=="mac"', {
'feature_defines': [
'ENABLE_RUBBER_BANDING=1',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment