I'd say, the closer to 1940 you come, the more likely it would become for Canada to not honour the Commonwealth and face a invasion. If the war however broke out in, let's say 1912, Canada would loyally have joined UK in the war.
In fact, in World War I, Britain (in the person of the King) declared war on Germany, and the Empire was at war.
World War II, (after discussion in Parliament) the King of the United Kingdom declares war on Germany. ?3? days later, (after discussion in Parliament) the King of Canada declares war on Germany
Many people forget that 'independence' is often not as cut and dried as in the US case. In the case of the Empire and its Dominions, the process was incredibly gradual. So, Canada was formed with Confederation in 1867 - but, on the one hand, the constituent colonies had already had local self government and on the other, even after confederation Canada didn't have full control of foreign policy. Various Imperial conferences in the interwar years devolved much more power onto the governments of the various white Dominions, so by WWII, Canada and Australia were de facto independent, but there is no single point at which you can say 'Aha, Canada is now independent'. Even much later, there were vestigial bits of non-independence - Canada's Constitution was an Act of the BRITISH Parliament until the '70s, for example. Similarly, my Grandad never officially took out Canadian citizenship - but (legally) voted in every Canadian election during his lifetime.
And a lot of the impetus for giving the Dominions more power/control over e.g. foreign policy was as a result of WWI where a) they contributed immensely to the British effort, and b) the devastation wrought killed not just individual soldiers by the millions but also empires and idealism.