diff --git a/dom/html/test/mochitest.ini b/dom/html/test/mochitest.ini
index 70bd4c62ffc8d..45982ec4781e6 100644
--- a/dom/html/test/mochitest.ini
+++ b/dom/html/test/mochitest.ini
@@ -582,7 +582,8 @@ skip-if = toolkit == 'android'
[test_bug741266.html]
skip-if = buildapp == "mulet" || buildapp == "b2g" || toolkit == "android" || toolkit == "windows" || e10s # b2g(needs control of popup window size) b2g-debug(needs control of popup window size) b2g-desktop(needs control of popup window size) windows(bug 1234520)
[test_non-ascii-cookie.html]
-skip-if = buildapp == 'b2g' || e10s
+skip-if = buildapp == 'b2g'
+support-files = file_cookiemanager.js
[test_bug765780.html]
[test_bug871161.html]
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
diff --git a/dom/html/test/test_non-ascii-cookie.html b/dom/html/test/test_non-ascii-cookie.html
index fc307265a659e..ab96ac07c2dc4 100644
--- a/dom/html/test/test_non-ascii-cookie.html
+++ b/dom/html/test/test_non-ascii-cookie.html
@@ -20,38 +20,40 @@
/** Test for non-ASCII cookie values **/
-var [Cc, Ci] = [SpecialPowers.Cc, SpecialPowers.Ci];
+SimpleTest.waitForExplicitFinish();
+
+var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL("file_cookiemanager.js"));
-var cm = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
function getCookieFromManager() {
- var values = [];
- var host = location.hostname;
- var path = location.pathname;
- path = path.substring(0, path.lastIndexOf("/") + 1);
- var e = cm.enumerator;
- while (e.hasMoreElements()) {
- var cookie = e.getNext().QueryInterface(Ci.nsICookie);
- if (!cookie) {
- break;
- }
- if (host != cookie.host || path != cookie.path) {
- continue;
- }
- values.push(cookie.name + "=" + cookie.value);
- }
- return values.join("; ");
+ return new Promise(resolve => {
+ gScript.addMessageListener("getCookieFromManager:return", function gcfm({ cookie }) {
+ gScript.removeMessageListener("getCookieFromManager:return", gcfm);
+ resolve(cookie);
+ });
+ gScript.sendAsyncMessage("getCookieFromManager", { host: location.hostname, path: location.pathname });
+ });
}
var c = document.cookie;
is(document.cookie, 'abc=012©ABC\ufffdDEF', "document.cookie should be decoded as UTF-8");
-is(getCookieFromManager(), document.cookie, "nsICookieManager should be consistent with document.cookie");
-var newCookie = 'def=∼≩≭≧∯≳≲≣∽≸≸∺≸∠≯≮≥≲≲≯≲∽≡≬≥≲≴∨∱∩∾';
-document.cookie = newCookie;
-is(document.cookie, c + '; ' + newCookie, "document.cookie should be encoded as UTF-8");
-is(getCookieFromManager(), document.cookie, "nsICookieManager should be consistent with document.cookie");
-var date1 = new Date();
-date1.setTime(0);
-document.cookie = newCookie + 'def=;expires=' + date1.toGMTString();
+
+var newCookie;
+
+getCookieFromManager().then((cookie) => {
+ is(cookie, document.cookie, "nsICookieManager should be consistent with document.cookie");
+ newCookie = 'def=∼≩≭≧∯≳≲≣∽≸≸∺≸∠≯≮≥≲≲≯≲∽≡≬≥≲≴∨∱∩∾';
+ document.cookie = newCookie;
+ is(document.cookie, c + '; ' + newCookie, "document.cookie should be encoded as UTF-8");
+
+ return getCookieFromManager();
+}).then((cookie) => {
+ is(cookie, document.cookie, "nsICookieManager should be consistent with document.cookie");
+ var date1 = new Date();
+ date1.setTime(0);
+ document.cookie = newCookie + 'def=;expires=' + date1.toGMTString();
+ gScript.destroy();
+ SimpleTest.finish();
+});