Before the Revolution, to hold public office or to gain the rights of a "freeman" who could vote, you usually had to take a public Oath of Allegiance of some sort. The form varied from colony to colony, and the form used was often selected to disenfranchise particular religious groups. For instance, once the British gained control Quebec at the end of the French and Indian War, they required office-holders and citizens who wanted voting rights to take the King's Declaration, which was a modified form of the "Test Oath" (i.e. the "Declaration of Attestation") which had been created and amended in 1672, 1678, and 1688:
"I, A.B. [your name], by the Grace of God King George of Great Britain and Ireland, Defender of the Faith, do solemnly and sincerely, in the presence of God, profess, testify, and declare that I do believe that in the Sacrament of the Lord's Supper there is not any transubstantiation of the elements of bread and wine into the Body and Blood of Christ, at or after the consecration thereof by any person whatsoever. And I do believe that the invocation or adoration of the Virgin Mary or any other saint, and the Sacrifice of the Mass, as they are now used in the Church of Rome, are contrary to the Protestant religion. And I do solemnly, in the presence of God, profess, testify, and declare that I do make this declaration and every part thereof unreservedly."
This led to a situation in Quebec where the vast majority of the people were disenfranchised from voting or holding office, since they were mostly Catholic. Fearing rebellion, as was happening in Massachusetts, Parliament passed the Quebec Act in 1774 which replaced the King's Declaration with a modified version of the Oath of Supremacy as it had existed under Queen Elizabeth I:
"I, A.B., do sincerely promise and swear, that I will be faithful, and bear true allegiance to his majesty King George, and him will defend to the utmost of my power, against all traitorous conspiracies and attempts whatsoever, which shall be made against his person, crown, and dignity; and I will do my utmost endeavour to disclose and make known to his majesty, his heirs and successors, all treasons and traitorous conspiracies and attempts, which I shall know to be against him, or any of them; and all this I do swear, without any equivocation, mental evasion, or secret reservations; and renouncing all pardons and dispensations from any power or person whomsoever to the contrary. So help me God."
Another group often disenfranchised were the Quakers, who refused to swear oaths altogether. Most colonies followed Parliament's Quaker Act of 1695, which allowed Quakers to "affirm a pledge" rather than "swear an oath". The body of the oath would be the same, but the beginning could be substituted, such as under New York law, where the "swear" part would be replaced with:
"I, [your name], do solemnly, sincerely, and truly declare and affirm..."
Massachusetts law was eventually similar:
"I, [your name], do solemnly and sincerely affirm and declare under the pains of the penalty of perjury..."
Other colonies, like New Jersey, resisted the enfranchisement of Quakers for some time after the Quaker Act was passed, but by the time of the Revolution, all the colonies had offered enfranchisement to Quakers, though not necessarily to Catholics, or non-Christians.
To that point, in early Plymouth and Massachusetts colonial history, the colonial governments hadn't been so inclusive, and initially required an oath that started:
"I, [your name], do truly and sincerely acknowledge, confess, testify, and declare in my Conscience before God and the World, that our Sovereign Lord King James is lawful and rightful King of this Realm and of all other his Majesty's Dominions and Countries; And that the Pope, neither of himself nor by any Authority of the Church or Sea of Rome, or by any other means with any other, hath any Power or Authority to depose the King or to dispose any of his Majesty's Kingdoms or Dominions, or to authorize any Foreign Prince to invade or annoy him or his Countries, or to discharge any of his Subjects of their Allegiance and Obedience to his Majesty, or to give Licence or Leave to any of them to bear Arms, raise Tumult, or to offer any violence or hurt to his Majesty, Royal Person, State, or Government, or to any of his Majesty's Subjects within his Majesty's Dominions..."
After more anti-Catholic language, the oath ended with:
"...And I do make this recognition and acknowledgment heartily, willingly, and truly upon the true Faith of a Christian: So help me God."
In effect, this oath disenfranchised Catholics, Quakers, and all non-Christians. It actually went a bit further than that for a while, in that you had to be a member of the church to hold office, and the Puritan churches required a personal conversion experience in order to join--that is, you had to be baptized in one of the colony's Congregationalist churches. This led to political controversy that essentially resulted in schisms leading to the formation of both Rhode Island and Connecticut, and the eventual adoption in Plymouth and Massachusetts of something called the "Half-Way Covenant" that allowed some enfranchisement of non-church members, so long as they took an oath in which they promised not to undermine the church in any way.
By the time of the Revolution, the oaths weren't so strict, however, some form of oath or affirmation was always required and it always included some mention of loyalty to the King, who was the head of the Church of England. The pre-war situation against Catholics in Quebec was followed by the post-war situation in Pennsylvania where there was an effort through a religious "test law" to disenfranchise Quakers and Mennonites because many of them had refused to serve during the war due to their pacifist religious beliefs. The Founders didn't want sizable communities of U.S. citizens to be disenfranchised based on the religious or political whims of a future President or Congress, fearing future rebellions. So, instead, the U.S. oaths and affirmations declared loyalty to the U.S. Constitution and to the law, and left religion out of it.
The U.S Code today requires civil servants and uniformed officers to declare this oath or affirmation:
"I, A.B., do solemnly swear (or affirm) that I will support and defend the Constitution of the United States against all enemies, foreign and domestic; that I will bear true faith and allegiance to the same; that I take this obligation freely, without any mental reservation or purpose of evasion; and that I will well and faithfully discharge the duties of the office on which I am about to enter. So help me God."
FURTHER READING:
The History of Publick and Solemn State Oaths, 1716
"Oaths of Allegiance in Colonial New England" by Charles Evans, Proceedings of the American Antiquarian Society, October 1921, pp. 377-438
Denizations, Naturalizations, and Oaths of Allegiance in Colonial New York by Kenneth Scott, Kenn Stryker-Rodda, 1975
Names Of Persons Who Took The Oath Of Allegiance To The State Of Pennsylvania Between 1777 and 1789; With a History of the "Test laws" of Pennsylvania by Thompson Wescott, 1865