blob: 3b164d60aa19f885ea5c03f055014b792d0826f4 [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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// https://www.w3.org/TR/2014/WD-XMLHttpRequest-20140130/#xmlhttprequest
[
Constructor,
ConstructorCallWith=EnvironmentSettings,
AddOpaqueRoots=("upload_or_null","response_array_buffer_or_null"),
] 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 https://xhr.spec.whatwg.org/#interface-xmlhttprequest.
[RaisesException] void send(
optional (DOMString or ArrayBufferView or ArrayBuffer)? request_body);
void abort();
// 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;