Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #21995 from KevinGrandon/bug_1041607_async_xhr_in_…
Browse files Browse the repository at this point in the history
…tests

Bug 1041607 - Remove synchronous XHR from tests
  • Loading branch information
KevinGrandon committed Jul 21, 2014
2 parents e236400 + f3fe5c3 commit 649245c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Expand Up @@ -57,12 +57,16 @@ marionette('Vertical - Collection', function() {
});
});

/*
// XXX: Loading this locale file seems to no longer work.
// Hardcode the expected value for now.
var expected = home.l10n(
'/locales-obj/qps-ploc.json',
// XXX: harcoded number 376 taken from the fixture
'collection-categoryId-376'
);

*/
var expected = 'Ḗḗƞŧḗḗřŧȧȧīīƞḿḗḗƞŧ'; // Entertainment
client.waitFor(function() {
return expected === collectionIcon.text();
});
Expand Down
18 changes: 8 additions & 10 deletions apps/verticalhome/test/marionette/lib/home2.js
Expand Up @@ -231,15 +231,14 @@ Home2.prototype = {
var client = this.client.scope({context: 'chrome'});

var file = 'app://' + app + '.gaiamobile.org/manifest.webapp';
var manifest = client.executeScript(function(file) {
var manifest = client.executeAsyncScript(function(file) {
var xhr = new XMLHttpRequest();
var data;
xhr.open('GET', file, false); // Intentional sync
xhr.open('GET', file, true);
xhr.onload = function(o) {
data = JSON.parse(xhr.response);
var data = JSON.parse(xhr.response);
marionetteScriptFinished(data);
};
xhr.send(null);
return data;
}, [file]);

var locales;
Expand All @@ -257,15 +256,14 @@ Home2.prototype = {
* @param {String} key of the string to lookup.
*/
l10n: function(file, key) {
var string = this.client.executeScript(function(file, key) {
var string = this.client.executeAsyncScript(function(file, key) {
var xhr = new XMLHttpRequest();
var data;
xhr.open('GET', file, false); // Intentional sync
xhr.open('GET', file, true);
xhr.onload = function(o) {
data = JSON.parse(xhr.response);
var data = JSON.parse(xhr.response);
marionetteScriptFinished(data);
};
xhr.send(null);
return data;
}, [file, key]);

return string[key];
Expand Down

0 comments on commit 649245c

Please sign in to comment.