From 746dd0bcf5f3b0e685d842252c620c01faff19b9 Mon Sep 17 00:00:00 2001 From: Andres Rey Date: Sat, 10 Mar 2018 17:49:00 +0000 Subject: Remove all class attributes from the tests --- test/test-pages/002/expected.html | 70 +++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'test/test-pages/002') diff --git a/test/test-pages/002/expected.html b/test/test-pages/002/expected.html index d836b60..16dca2a 100644 --- a/test/test-pages/002/expected.html +++ b/test/test-pages/002/expected.html @@ -1,4 +1,4 @@ -

For more than a decade the Web has used XMLHttpRequest (XHR) to achieve +

For more than a decade the Web has used XMLHttpRequest (XHR) to achieve asynchronous requests in JavaScript. While very useful, XHR is not a very nice API. It suffers from lack of separation of concerns. The input, output and state are all managed by interacting with one object, and state is @@ -29,8 +29,8 @@

The most useful, high-level part of the Fetch API is the fetch() function. In its simplest form it takes a URL and returns a promise that resolves to the response. The response is captured as a Response object.

-
-
fetch("/data.json").then(function(res) {
+                        
+
fetch("/data.json").then(function(res) {
   // res instanceof Response == true.
   if (res.ok) {
     res.json().then(function(data) {
@@ -45,8 +45,8 @@
                                         

Submitting some parameters, it would look like this:

-
-
fetch("http://www.example.org/submit.php", {
+            
+
fetch("http://www.example.org/submit.php", {
   method: "POST",
   headers: {
     "Content-Type": "application/x-www-form-urlencoded"
@@ -78,8 +78,8 @@
                 

supporting CORS rules and ensuring cookies aren’t readable by third parties.

The Headers interface is a simple multi-map of names to values:

-
-
var content = "Hello World";
+            
+
var content = "Hello World";
 var reqHeaders = new Headers();
 reqHeaders.append("Content-Type", "text/plain"
 reqHeaders.append("Content-Length", content.length.toString());
@@ -89,8 +89,8 @@ reqHeaders.append("X-Custom-Header"
             

The same can be achieved by passing an array of arrays or a JS object literal

to the constructor:

-
-
reqHeaders = new Headers({
+            
+
reqHeaders = new Headers({
   "Content-Type": "text/plain",
   "Content-Length": content.length.toString(),
   "X-Custom-Header": "ProcessThisImmediately",
@@ -98,8 +98,8 @@ reqHeaders.append("X-Custom-Header"
                             

The contents can be queried and retrieved:

-
-
console.log(reqHeaders.has("Content-Type")); // true
+            
+
console.log(reqHeaders.has("Content-Type")); // true
 console.log(reqHeaders.has("Set-Cookie")); // false
 reqHeaders.set("Content-Type", "text/html");
 reqHeaders.append("X-Custom-Header", "AnotherValue");
@@ -135,8 +135,8 @@ console.log(reqHeaders.getAll(All of the Headers methods throw TypeError if name is not a
                 valid HTTP Header name. The mutation operations will throw TypeError
                     if there is an immutable guard. Otherwise they fail silently. For example:

-
-
var res = Response.error();
+            
+
var res = Response.error();
 try {
   res.headers.set("Origin", "http://mybank.com");
 } catch(e) {
@@ -152,8 +152,8 @@ console.log(reqHeaders.getAll(
         

The simplest Request is of course, just a URL, as you may do to GET a resource.

-
-
var req = new Request("/index.html");
+        
+ @@ -163,8 +163,8 @@ console.log(req.url);<

(This is not the same as calling the clone() method, which is covered in

the “Reading bodies” section.).

-
-
var req = new Request("/index.html");
 console.log(req.method); // "GET"
 console.log(req.url); // "http://example.com/index.html"
var copy = new Request(req);
+        
+ @@ -173,8 +173,8 @@ console.log(copy.url);

The non-URL attributes of the Request can only be set by passing initial

values as a second argument to the constructor. This argument is a dictionary.

-
-
var copy = new Request(req);
 console.log(copy.method); // "GET"
 console.log(copy.url); // "http://example.com/index.html"
var uploadReq = new Request("/uploadImage", {
+        
+
var uploadReq = new Request("/uploadImage", {
   method: "POST",
   headers: {
     "Content-Type": "image/png",
@@ -191,8 +191,8 @@ console.log(copy.url);
                 origin with this mode set, the result is simply an error. You could use
                 this to ensure that
                 

a request is always being made to your origin.

-
-
var arbitraryUrl = document.getElementById("url-input").value;
+            
+
var arbitraryUrl = document.getElementById("url-input").value;
 fetch(arbitraryUrl, { mode: "same-origin" }).then(function(res) {
   console.log("Response succeeded?", res.ok);
 }, function(e) {
@@ -217,8 +217,8 @@ fetch(arbitraryUrl, { mode:
                 headers is exposed in the Response, but the body is readable. For example,
                 you could get a list of Flickr’s most interesting photos
                 today like this:

-
-
var u = new URLSearchParams();
+            
+
var u = new URLSearchParams();
 u.append('method', 'flickr.interestingness.getList');
 u.append('api_key', '<insert api key here>');
 u.append('format', 'json');
@@ -241,8 +241,8 @@ apiCall.then(function(respon
             

You may not read out the “Date” header since Flickr does not allow it via

Access-Control-Expose-Headers.

-
-
response.headers.get("Date"); // null
+
+
response.headers.get("Date"); // null

The credentials enumeration determines if cookies for the other @@ -296,8 +296,8 @@ apiCall.then(function(respon The

idiomatic way to return a Response to an intercepted request in ServiceWorkers is:

-
-
addEventListener('fetch', function(event) {
+            
+
addEventListener('fetch', function(event) {
   event.respondWith(new Response("Response body", {
     headers: { "Content-Type" : "text/plain" }
   });
@@ -347,8 +347,8 @@ apiCall.then(function(respon
             

This is a significant improvement over XHR in terms of ease of use of non-text data!

Request bodies can be set by passing body parameters:

-
-
var form = new FormData(document.getElementById('login-form'));
+            
+
var form = new FormData(document.getElementById('login-form'));
 fetch("/login", {
   method: "POST",
   body: form
@@ -356,8 +356,8 @@ fetch("/login", {
                             

Responses take the first argument as the body.

-
-
var res = new Response(new File(["chunk", "chunk"], "archive.zip",
+                
+
var res = new Response(new File(["chunk", "chunk"], "archive.zip",
                        { type: "application/zip" }));
@@ -371,8 +371,8 @@ fetch("/login", {

It is important to realise that Request and Response bodies can only be read once! Both interfaces have a boolean attribute bodyUsed to determine if it is safe to read or not.

-
-
var res = new Response("one time use");
+                
+
var res = new Response("one time use");
 console.log(res.bodyUsed); // false
 res.text().then(function(v) {
   console.log(res.bodyUsed); // true
@@ -397,8 +397,8 @@ res.text().catch(clone() MUST
                     be called before the body of the corresponding object has been used. That
                     is, clone() first, read later.

-
-
addEventListener('fetch', function(evt) {
+                
+
addEventListener('fetch', function(evt) {
   var sheep = new Response("Dolly");
   console.log(sheep.bodyUsed); // false
   var clone = sheep.clone();
-- 
cgit v1.2.3