Vikrant and i were able to confirm that as long as the feature layers are instantiated in the order they are displayed in the map, the infoWindow displays the attributes which correspond with the correct layer.
//instantiate the featureLayer you would like to draw on top first
pointsOfInterest = new esri.layers.FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0",{
mode: esri.layers.FeatureLayer.MODE_ONDEMAND, //QUERY_SELECTION is working as well
outFields: ['*']
});
//second
WildfireLine = new esri.layers.FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/1",{
mode: esri.layers.FeatureLayer.MODE_ONDEMAND, //QUERY_SELECTION is working as well
outFields: ['*']
});
//polygons last
evacuationPerimeter = new esri.layers.FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/2",{
mode: esri.layers.FeatureLayer.MODE_ONDEMAND, //QUERY_SELECTION is working as well
outFields: ['*']
});
//in the array of featureLayers to add, specify the bottom layer first
map.addLayers([evacuationPerimeter,WildfireLine,pointsOfInterest]);