blob: 176e6c2a65cc157e217c712b0e5b61578db98f8a [file] [log] [blame]
// Copyright 2015 Google Inc. All Rights Reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
] interface XMLHttpRequest : XMLHttpRequestEventTarget {
// event handler
attribute EventHandler onreadystatechange;
// states
const unsigned short UNSENT = 0;
const unsigned short OPENED = 1;
const unsigned short HEADERS_RECEIVED = 2;
const unsigned short LOADING = 3;
const unsigned short DONE = 4;
readonly attribute unsigned short readyState;
// request
[RaisesException] void open(DOMString method, DOMString url);
[RaisesException] void open(DOMString method, DOMString url,
boolean async,
optional DOMString? username,
optional DOMString? password);
[RaisesException] void setRequestHeader(DOMString header, DOMString value);
attribute unsigned long timeout;
[RaisesException=Setter] attribute boolean withCredentials;
readonly attribute XMLHttpRequestUpload upload;
// TODO: Upgrade to void send(optional (Document or BodyInit)? body = null);
// See
[RaisesException] void send(
optional (DOMString or ArrayBufferView or ArrayBuffer)? request_body);
void abort();
// FetchAPI: replacement for "send" when fetch functionality is needed.
[RaisesException] void fetch(
FetchUpdateCallback fetch_callback, FetchModeCallback mode_callback,
(DOMString or ArrayBufferView or ArrayBuffer)? request_body);
// response
readonly attribute unsigned short status;
readonly attribute DOMString statusText;
DOMString? getResponseHeader(DOMString header);
DOMString getAllResponseHeaders();
[RaisesException] void overrideMimeType(DOMString mime_type);
[RaisesException=Setter] attribute DOMString responseType;
// TODO: Use a union type for all the possible response types.
[RaisesException] readonly attribute (DOMString or ArrayBuffer) response;
[RaisesException] readonly attribute DOMString responseText;
[RaisesException] readonly attribute Document? responseXML;
// Not part of the spec. Enable verbose XHR logging.
static attribute boolean verbose;
// TODO: The IDL defines EventHandler as a nullable callback function. Define it
// as a nullable EventListener for now until we can do some refactoring to
// accept both in the EventTarget implementation.
typedef EventListener? EventHandler;
// FetchAPI: custom callback to allow progressive updates.
callback FetchUpdateCallback = void(Uint8Array data);
// FetchAPI: custom callback to distinguish between mode.
callback FetchModeCallback = void(boolean is_cors_mode);