Bug 1017613 - Part 3 - fetch() IDL and stubs. r=baku

--HG--
extra : rebase_source : 7783234b38b5d903dd6bd6d1e25d97c2e739f78c
This commit is contained in:
Nikhil Marathe 2014-07-24 18:30:07 -07:00
Родитель 75d95732ee
Коммит 6e02b27ae9
8 изменённых файлов: 38 добавлений и 0 удалений

Просмотреть файл

@ -187,6 +187,7 @@
#include "mozilla/dom/MessagePort.h"
#include "mozilla/dom/MessagePortBinding.h"
#include "mozilla/dom/indexedDB/IDBFactory.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/StructuredCloneTags.h"
@ -6370,6 +6371,14 @@ nsGlobalWindow::Confirm(const nsAString& aString, bool* aReturn)
return rv.ErrorCode();
}
already_AddRefed<Promise>
nsGlobalWindow::Fetch(const RequestOrScalarValueString& aInput,
const RequestInit& aInit, ErrorResult& aRv)
{
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
return nullptr;
}
void
nsGlobalWindow::Prompt(const nsAString& aMessage, const nsAString& aInitial,
nsAString& aReturn, ErrorResult& aError)

Просмотреть файл

@ -38,8 +38,10 @@
#include "nsSize.h"
#include "mozFlushType.h"
#include "prclist.h"
#include "mozilla/dom/RequestBinding.h"
#include "mozilla/dom/StorageEvent.h"
#include "mozilla/dom/StorageEventBinding.h"
#include "mozilla/dom/UnionTypes.h"
#include "nsFrameMessageManager.h"
#include "mozilla/LinkedList.h"
#include "mozilla/TimeStamp.h"
@ -107,6 +109,7 @@ class MediaQueryList;
class MozSelfSupport;
class Navigator;
class OwningExternalOrWindowProxy;
class Promise;
class Selection;
class SpeechSynthesis;
class WakeLock;
@ -850,6 +853,9 @@ public:
void Alert(mozilla::ErrorResult& aError);
void Alert(const nsAString& aMessage, mozilla::ErrorResult& aError);
bool Confirm(const nsAString& aMessage, mozilla::ErrorResult& aError);
already_AddRefed<mozilla::dom::Promise> Fetch(const mozilla::dom::RequestOrScalarValueString& aInput,
const mozilla::dom::RequestInit& aInit,
mozilla::ErrorResult& aRv);
void Prompt(const nsAString& aMessage, const nsAString& aInitial,
nsAString& aReturn, mozilla::ErrorResult& aError);
void Print(mozilla::ErrorResult& aError);

Просмотреть файл

@ -27,3 +27,10 @@ interface Body {
[Throws]
Promise<ScalarValueString> text();
};
[NoInterfaceObject, Exposed=(Window,Worker)]
interface GlobalFetch {
[Throws, Func="mozilla::dom::Headers::PrefEnabled"]
Promise<Response> fetch(RequestInfo input, optional RequestInit init);
};

Просмотреть файл

@ -465,3 +465,4 @@ interface ChromeWindow {
};
Window implements ChromeWindow;
Window implements GlobalFetch;

Просмотреть файл

@ -38,6 +38,7 @@ partial interface WorkerGlobalScope {
WorkerGlobalScope implements WindowTimers;
WorkerGlobalScope implements WindowBase64;
WorkerGlobalScope implements GlobalFetch;
// Not implemented yet: bug 1072107.
// WorkerGlobalScope implements FontFaceSource;

Просмотреть файл

@ -303,6 +303,14 @@ WorkerGlobalScope::GetPerformance()
return mPerformance;
}
already_AddRefed<Promise>
WorkerGlobalScope::Fetch(const RequestOrScalarValueString& aInput,
const RequestInit& aInit, ErrorResult& aRv)
{
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
return nullptr;
}
DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate)
: WorkerGlobalScope(aWorkerPrivate)
{

Просмотреть файл

@ -8,6 +8,8 @@
#include "Workers.h"
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/RequestBinding.h"
#include "mozilla/dom/UnionTypes.h"
namespace mozilla {
namespace dom {
@ -120,6 +122,9 @@ public:
Dump(const Optional<nsAString>& aString) const;
Performance* GetPerformance();
already_AddRefed<Promise>
Fetch(const RequestOrScalarValueString& aInput, const RequestInit& aInit, ErrorResult& aRv);
};
class DedicatedWorkerGlobalScope MOZ_FINAL : public WorkerGlobalScope

Просмотреть файл

@ -7,5 +7,6 @@ onmessage = function() {
ok(typeof Headers === "function", "Headers should be defined");
ok(typeof Request === "function", "Request should be defined");
ok(typeof Response === "function", "Response should be defined");
ok(typeof fetch === "function", "fetch() should be defined");
postMessage({ type: 'finish' });
}