Skip to content

Commit

Permalink
Merge branch 'master' into FLUID-6180
Browse files Browse the repository at this point in the history
  • Loading branch information
jobara committed Oct 19, 2017
2 parents 3bb9a83 + 4612ab5 commit bb842d1
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 16 deletions.
16 changes: 4 additions & 12 deletions src/framework/core/js/FluidRequests.js
Expand Up @@ -333,13 +333,9 @@ var fluid_3_0_0 = fluid_3_0_0 || {};

fluid.fetchResources.fetchResourcesImpl = function (that) {
var complete = true;
var allSync = true;
var resourceSpecs = that.resourceSpecs;
for (var key in resourceSpecs) {
var resourceSpec = resourceSpecs[key];
if (!resourceSpec.options || resourceSpec.options.async) {
allSync = false;
}
if (resourceSpec.href && !resourceSpec.completeTime) {
if (!resourceSpec.queued) {
fluid.fetchResources.issueRequest(resourceSpec, key);
Expand All @@ -358,15 +354,11 @@ var fluid_3_0_0 = fluid_3_0_0 || {};
}
if (complete && that.callback && !that.callbackCalled) {
that.callbackCalled = true;
if ($.browser.mozilla && !allSync) {
// Defer this callback to avoid debugging problems on Firefox
setTimeout(function () {
fluid.fetchResources.notifyResources(that, resourceSpecs, that.callback);
}, 1);
}
else {
// Always defer notification in an anti-Zalgo scheme to ease problems like FLUID-6202
// In time this will be resolved by i) latched events, ii) global async ginger world
setTimeout(function () {
fluid.fetchResources.notifyResources(that, resourceSpecs, that.callback);
}
}, 1);
}
};

Expand Down
49 changes: 49 additions & 0 deletions tests/framework-tests/core/js/FluidIoCTests.js
Expand Up @@ -1839,6 +1839,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
});

/** FLUID-5112: Composite event firing test **/

fluid.defaults("fluid.tests.composite.test", {
gradeNames: ["fluid.component"],
events: {
Expand Down Expand Up @@ -1881,7 +1882,55 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
}
});
});

/** FLUID-6202: merging over composite event **/

fluid.defaults("fluid.tests.FLUID6202parent", {
gradeNames: "fluid.component",
members: {
fireCount: 0
},
events: {
baseEvent: null,
compositeEvent: {
events: {
baseEvent: "baseEvent"
}
}
},
listeners: {
compositeEvent: "fluid.tests.FLUID6202recordFire({that})"
}
});

fluid.tests.FLUID6202recordFire = function (that) {
++that.fireCount;
};

fluid.defaults("fluid.tests.FLUID6202child", {
gradeNames: "fluid.tests.FLUID6202parent",
events: {
childEvent: null,
compositeEvent: {
events: {
childEvent: "childEvent"
}
}
}
});

jqUnit.test("FLUID-6202: Merging over composite event", function () {
var that = fluid.tests.FLUID6202child();
jqUnit.assertEquals("No firing at start", 0, that.fireCount);
that.events.childEvent.fire();
jqUnit.assertEquals("No firing with child event", 0, that.fireCount);
that.events.baseEvent.fire();
jqUnit.assertEquals("1 firing with base event", 1, that.fireCount);
that.events.baseEvent.fire();
jqUnit.assertEquals("No firing with base event", 1, that.fireCount);
that.events.childEvent.fire();
jqUnit.assertEquals("One firing with child event", 2, that.fireCount);
});

/** FLUID-4135 - simple event injection test **/
Expand Down
43 changes: 43 additions & 0 deletions tests/framework-tests/core/js/ResourceLoaderTests.js
Expand Up @@ -111,4 +111,47 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
jqUnit.expect(1);
fluid.tests.UI(".flc-container");
});

/** FLUID-6202: testing real cause of fault, synchrony in FluidRequests.js **/

fluid.defaults("fluid.tests.FLUID6202parent2", {
gradeNames: "fluid.component",
events: {
compositeEvent: {
events: {
templateLoader: "{that}.templateLoader.events.onResourcesLoaded",
messageLoader: "{that}.messageLoader.events.onResourcesLoaded"
}
}
},
components: {
templateLoader: {
type: "fluid.tests.FLUID6202resources"
},
messageLoader: {
type: "fluid.tests.FLUID6202resources"
}
}
});

fluid.defaults("fluid.tests.FLUID6202resources", {
gradeNames: "fluid.resourceLoader",
resources: {
template1: "../data/testTemplate1.html"
}
});

jqUnit.asyncTest("FLUID-6202: Forced instantiation of resource loaders with cached content", function () {
jqUnit.expect(1);
var restart = function () {
jqUnit.assert("Composite event has fired");
jqUnit.start();
};
fluid.tests.FLUID6202parent2({
listeners: {
compositeEvent: restart
}
});
});

})();
7 changes: 3 additions & 4 deletions tests/framework-tests/renderer/js/RendererTests.js
Expand Up @@ -1545,18 +1545,17 @@
}
};

jqUnit.test("fetchResources callback tests", function () {
var callbackCalled = 0;
jqUnit.asyncTest("fetchResources callback tests", function () {
function callback() {
++callbackCalled;
jqUnit.assert("Call to overall callback");
fluid.failureEvent.removeListener("jqUnit"); // restore the original jqUnit test failing listener
jqUnit.start();
}
jqUnit.expect(2);
fluid.failureEvent.addListener(fluid.identity, "jqUnit"); // temporarily displace jqUnit's test failing listener
fluid.fetchResources(resourceSpec2, callback);

jqUnit.assertEquals("Two calls to destructive callback", 2, destructiveCalls);
jqUnit.assertEquals("Call to overall callback", 1, callbackCalled);
});

var resourceSpec3 = {
Expand Down

0 comments on commit bb842d1

Please sign in to comment.