When I transferred temporarily (!) from Ford of Canada to Ford in the US, my income tax was calculated based upon the residency, regardless of origin of pay. My friends who transferred the opposite way also played under those rules. There is income tax reciprocity between Canada and the US because of the tax treaty. This is not the case with most countries, though. You need to investigate each pair of countries individually.
Residency is based upon certain requirements, usually involving length of temporary residence, marriage or other special consideration including refugee status.
Citizenship in Canada requires length of permanent residency without criminal record, deviancy, or drinking Coor's Light (proof of copious Molson consumption must be documented).