Commit 4f6cc985 authored by avayvod@chromium.org's avatar avayvod@chromium.org

The rest of the Presentation API IDL as stubs.

BUG=412331

Review URL: https://codereview.chromium.org/685263003

git-svn-id: svn://svn.chromium.org/blink/trunk@184806 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2aa67713
......@@ -45,6 +45,7 @@ PASS window.cached_navigator.vendor is window.navigator.vendor
PASS window.cached_navigator.vendorSub is ''
PASS window.cached_navigator_connection.ontypechange is null
PASS window.cached_navigator_presentation.onavailablechange is null
PASS window.cached_navigator_presentation.session is null
PASS window.cached_navigator_serviceWorker.controller is null
PASS window.cached_performance.onwebkitresourcetimingbufferfull is null
PASS window.cached_performance_navigation.redirectCount is 0
......
......@@ -45,6 +45,7 @@ PASS window.cached_navigator.vendor is window.navigator.vendor
PASS window.cached_navigator.vendorSub is ''
PASS window.cached_navigator_connection.ontypechange is null
PASS window.cached_navigator_presentation.onavailablechange is null
PASS window.cached_navigator_presentation.session is null
PASS window.cached_navigator_serviceWorker.controller is null
PASS window.cached_performance.onwebkitresourcetimingbufferfull is null
PASS window.cached_performance_navigation.redirectCount is 0
......
......@@ -45,6 +45,7 @@ PASS window.cached_navigator.vendor is window.navigator.vendor
PASS window.cached_navigator.vendorSub is ''
PASS window.cached_navigator_connection.ontypechange is null
PASS window.cached_navigator_presentation.onavailablechange is null
PASS window.cached_navigator_presentation.session is null
PASS window.cached_navigator_serviceWorker.controller is null
PASS window.cached_performance.onwebkitresourcetimingbufferfull is null
PASS window.cached_performance_navigation.redirectCount is 0
......
......@@ -51,6 +51,7 @@ PASS oldChildWindow.navigator.maxTouchPoints is newChildWindow.navigator.maxTouc
PASS oldChildWindow.navigator.onLine is newChildWindow.navigator.onLine
PASS oldChildWindow.navigator.platform is newChildWindow.navigator.platform
PASS oldChildWindow.navigator.presentation.onavailablechange is newChildWindow.navigator.presentation.onavailablechange
PASS oldChildWindow.navigator.presentation.session is newChildWindow.navigator.presentation.session
PASS oldChildWindow.navigator.product is newChildWindow.navigator.product
PASS oldChildWindow.navigator.productSub is newChildWindow.navigator.productSub
PASS oldChildWindow.navigator.serviceWorker.controller is newChildWindow.navigator.serviceWorker.controller
......
......@@ -51,6 +51,7 @@ PASS childWindow.navigator.maxTouchPoints is 0
PASS childWindow.navigator.onLine is window.navigator.onLine
PASS childWindow.navigator.platform is window.navigator.platform
FAIL childWindow.navigator.presentation.onavailablechange should be null. Threw exception TypeError: Cannot read property 'onavailablechange' of null
FAIL childWindow.navigator.presentation.session should be null. Threw exception TypeError: Cannot read property 'session' of null
PASS childWindow.navigator.product is window.navigator.product
PASS childWindow.navigator.productSub is window.navigator.productSub
FAIL childWindow.navigator.serviceWorker.controller should be null. Threw exception TypeError: Cannot read property 'controller' of null
......
......@@ -50,6 +50,7 @@ PASS childWindow.navigator.maxTouchPoints is 0
PASS childWindow.navigator.onLine is window.navigator.onLine
PASS childWindow.navigator.platform is window.navigator.platform
PASS childWindow.navigator.presentation.onavailablechange is null
PASS childWindow.navigator.presentation.session is null
PASS childWindow.navigator.product is window.navigator.product
PASS childWindow.navigator.productSub is window.navigator.productSub
PASS childWindow.navigator.serviceWorker.controller is null
......
......@@ -7,11 +7,17 @@
test(function() {
assert_true('presentation' in navigator);
assert_true('session' in navigator.presentation);
assert_true('startSession' in navigator.presentation);
assert_true('joinSession' in navigator.presentation);
assert_true('onavailablechange' in navigator.presentation);
}, "Test that the Presentation API is present.")
test(function() {
assert_equals(typeof(navigator.presentation), "object");
assert_equals(typeof(navigator.presentation.session), "object");
assert_equals(typeof(navigator.presentation.startSession), "function");
assert_equals(typeof(navigator.presentation.joinSession), "function");
assert_equals(typeof(navigator.presentation.onavailablechange), "object");
}, "Test the Presentation API property types.");
......
......@@ -282,6 +282,7 @@ Plugin
PluginArray
PopStateEvent
Presentation
PresentationSession
ProcessingInstruction
ProgressEvent
Promise
......
......@@ -19,6 +19,7 @@ modules/mediastream/RTCPeerConnection
modules/netinfo/NetworkInformation
modules/notifications/Notification
modules/presentation/Presentation
modules/presentation/PresentationSession
modules/screen_orientation/ScreenOrientation
modules/serviceworkers/ServiceWorker
modules/serviceworkers/ServiceWorkerGlobalScope
......
......@@ -117,6 +117,7 @@
'notifications/NotificationPermissionCallback.idl',
'performance/WorkerPerformance.idl',
'presentation/Presentation.idl',
'presentation/PresentationSession.idl',
'push_messaging/PushEvent.idl',
'push_messaging/PushManager.idl',
'push_messaging/PushRegistration.idl',
......@@ -689,6 +690,8 @@
'presentation/NavigatorPresentation.h',
'presentation/Presentation.cpp',
'presentation/Presentation.h',
'presentation/PresentationSession.cpp',
'presentation/PresentationSession.h',
'push_messaging/NavigatorPushManager.cpp',
'push_messaging/NavigatorPushManager.h',
'push_messaging/PushController.cpp',
......
avayvod@chromium.org
mfoltz@chromium.org
......@@ -5,6 +5,10 @@
#include "config.h"
#include "modules/presentation/Presentation.h"
#include "bindings/core/v8/ScriptPromise.h"
#include "bindings/core/v8/ScriptPromiseResolver.h"
#include "bindings/core/v8/ScriptState.h"
#include "core/dom/DOMException.h"
#include "modules/EventTargetModules.h"
namespace blink {
......@@ -36,7 +40,29 @@ ExecutionContext* Presentation::executionContext() const
void Presentation::trace(Visitor* visitor)
{
visitor->trace(m_session);
EventTargetWithInlineData::trace(visitor);
}
PresentationSession* Presentation::session() const
{
return m_session.get();
}
ScriptPromise Presentation::startSession(ScriptState* state, const String& senderId, const String& presentationId)
{
RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(state);
ScriptPromise promise = resolver->promise();
resolver->reject(DOMException::create(NotSupportedError, "The method is not supported yet."));
return promise;
}
ScriptPromise Presentation::joinSession(ScriptState* state, const String& senderId, const String& presentationId)
{
RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(state);
ScriptPromise promise = resolver->promise();
resolver->reject(DOMException::create(NotSupportedError, "The method is not supported yet."));
return promise;
}
} // namespace blink
......@@ -5,11 +5,15 @@
#ifndef Presentation_h
#define Presentation_h
#include "bindings/core/v8/ScriptPromise.h"
#include "core/dom/ContextLifecycleObserver.h"
#include "core/events/EventTarget.h"
#include "modules/presentation/PresentationSession.h"
namespace blink {
class ScriptState;
class Presentation final
: public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<Presentation>
, public EventTargetWithInlineData
......@@ -27,10 +31,17 @@ public:
virtual void trace(Visitor*) override;
PresentationSession* session() const;
ScriptPromise startSession(ScriptState*, const String& senderId, const String& presentationId);
ScriptPromise joinSession(ScriptState*, const String& senderId, const String& presentationId);
DEFINE_ATTRIBUTE_EVENT_LISTENER(availablechange);
private:
explicit Presentation(ExecutionContext*);
Member<PresentationSession> m_session;
};
} // namespace blink
......
......@@ -2,11 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// http://webscreens.github.io/presentation-api/#presentation-interface
// http://webscreens.github.io/presentation-api/#navigatorpresentation
[
GarbageCollected,
RuntimeEnabled=Presentation
] interface Presentation : EventTarget {
readonly attribute PresentationSession? session;
[CallWith=ScriptState] Promise<PresentationSession> startSession(DOMString senderId, [Default=Undefined] optional DOMString presentationId);
[CallWith=ScriptState] Promise<PresentationSession> joinSession(DOMString senderId, [Default=Undefined] optional DOMString presentationId);
attribute EventHandler onavailablechange;
};
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "modules/presentation/PresentationSession.h"
#include "modules/EventTargetModules.h"
namespace blink {
PresentationSession::PresentationSession(ExecutionContext* executionContext)
: ContextLifecycleObserver(executionContext)
{
}
PresentationSession::~PresentationSession()
{
}
// static
PresentationSession* PresentationSession::create(ExecutionContext* executionContext)
{
return new PresentationSession(executionContext);
}
const AtomicString& PresentationSession::interfaceName() const
{
return EventTargetNames::PresentationSession;
}
ExecutionContext* PresentationSession::executionContext() const
{
return ContextLifecycleObserver::executionContext();
}
void PresentationSession::trace(Visitor* visitor)
{
EventTargetWithInlineData::trace(visitor);
}
void PresentationSession::postMessage(const String& message)
{
}
void PresentationSession::close()
{
}
} // namespace blink
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PresentationSession_h
#define PresentationSession_h
#include "core/dom/ContextLifecycleObserver.h"
#include "core/events/EventTarget.h"
#include "wtf/text/AtomicString.h"
#include "wtf/text/WTFString.h"
namespace blink {
class PresentationSession final
: public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<PresentationSession>
, public EventTargetWithInlineData
, public ContextLifecycleObserver {
DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<PresentationSession>);
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PresentationSession);
DEFINE_WRAPPERTYPEINFO();
public:
static PresentationSession* create(ExecutionContext*);
virtual ~PresentationSession();
// EventTarget implementation.
virtual const AtomicString& interfaceName() const override;
virtual ExecutionContext* executionContext() const override;
virtual void trace(Visitor*) override;
const String& id() const { return m_id; }
const AtomicString& state() const { return m_state; }
void postMessage(const String& message);
void close();
DEFINE_ATTRIBUTE_EVENT_LISTENER(message);
DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange);
private:
explicit PresentationSession(ExecutionContext*);
String m_id;
AtomicString m_state;
};
} // namespace blink
#endif // PresentationSession_h
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// http://webscreens.github.io/presentation-api/#presentationsession
enum PresentationSessionState {
"connected",
"disconnected"
};
[
GarbageCollected,
RuntimeEnabled=Presentation
] interface PresentationSession : EventTarget {
readonly attribute DOMString? id;
readonly attribute PresentationSessionState state;
void postMessage(DOMString message);
void close();
attribute EventHandler onmessage;
attribute EventHandler onstatechange;
};
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