Bug 1162729 - CORS check is always performed when fetching a manifest. r=ehsan
authorMarcos Caceres <marcos@marcosc.com>
Thu, 07 May 2015 14:40:00 +0200
changeset 243376 f77c6a5d17d7c14fcdf20bbb66715f8322eebc33
parent 243375 03b10fccd3d8bbbc3431931d79e7eb8e2911b751
child 243377 6afb088b0cff22dcbdf88ba0d5c1291889d1e7e8
push id59667
push usercbook@mozilla.com
push dateTue, 12 May 2015 07:10:52 +0000
treeherdermozilla-inbound@6afb088b0cff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1162729
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1162729 - CORS check is always performed when fetching a manifest. r=ehsan
dom/ipc/manifestMessages.js
dom/manifest/test/browser_ManifestObtainer_obtain.js
--- a/dom/ipc/manifestMessages.js
+++ b/dom/ipc/manifestMessages.js
@@ -64,30 +64,21 @@ function fetchManifest() {
     }
     const elem = content.document.querySelector(manifestQuery);
     if (!elem || !elem.getAttribute('href')) {
       let msg = 'No manifest to fetch.';
       return reject(new Error(msg));
     }
     // Will throw on "about:blank" and possibly other invalid URIs.
     const manifestURL = new content.URL(elem.href, elem.baseURI);
-    const reqInit = {};
-    switch (elem.crossOrigin) {
-      case 'use-credentials':
-        reqInit.credentials = 'include';
-        reqInit.mode = 'cors';
-        break;
-      case 'anonymous':
-        reqInit.credentials = 'omit';
-        reqInit.mode = 'cors';
-        break;
-      default:
-        reqInit.credentials = 'same-origin';
-        reqInit.mode = 'no-cors';
-        break;
+    const reqInit = {
+      mode: 'cors'
+    };
+    if (elem.crossOrigin === 'use-credentials') {
+      reqInit.credentials = 'include';
     }
     const req = new content.Request(manifestURL, reqInit);
     req.setContext('manifest');
     content
       .fetch(req)
       .then(resp => processResponse(resp, content))
       .then(resolve)
       .catch(reject);
--- a/dom/manifest/test/browser_ManifestObtainer_obtain.js
+++ b/dom/manifest/test/browser_ManifestObtainer_obtain.js
@@ -39,28 +39,27 @@ const tests = [
     run(manifest) {
       Assert.strictEqual(manifest.name, 'pass-2', this.expected);
     },
     testData: `
       <link rel="foo bar manifest bar test" href='resource.sjs?body={"name":"pass-2"}'>
       <link rel="manifest" href='resource.sjs?body={"name":"fail"}'>
       <link rel="manifest foo bar test" href='resource.sjs?body={"name":"fail"}'>`
   }, {
-    expected: 'By default, manifest load cross-origin.',
+    expected: 'By default, manifest cannot load cross-origin.',
     get tabURL() {
       let query = [
         `body=<h1>${this.expected}</h1>`,
         'Content-Type=text/html; charset=utf-8',
       ];
       const URL = `${defaultURL}?${query.join('&')}`;
       return URL;
     },
-    run(manifest) {
-      // Waiting on https://bugzilla.mozilla.org/show_bug.cgi?id=1130924
-      todo_is(manifest.name, 'pass-3', this.expected);
+    run(err) {
+      Assert.strictEqual(err.name, 'TypeError', this.expected);
     },
     testData: `<link rel="manifest" href='${remoteURL}?body={"name":"pass-3"}'>`
   },
   // CORS Tests.
   {
     expected: 'CORS enabled, manifest must be fetched.',
     get tabURL() {
       let query = [