Sony says you shouldn't use the Xperia XZ1 and XZ1 Compact underwater, despite them being water-resistant
"Xperia XZ1 is water resistant and protected against dust, so don’t worry if you get caught in the rain or want to wash off dirt under the faucet water, but remember all ports and attached covers should be firmly closed. You should not put the device completely underwater; or expose it to seawater, salt water, chlorinated water, or liquids such as drinks. Abuse and improper use of device will invalidate warranty. The device has been tested under Ingress Protection rating IP65/68. For more info, see www.sonymobile.com/waterresistant. Note the Xperia XZ1 has a capless USB port to connect and charge. The USB port must be completely dry before charging."
So, there you go. While the XZ1 and XZ1 Compact could very well survive being underwater for some time, it's probably better not to test that. This is (likely) because IP certifications are given following tests made in controlled laboratory environments - which may differ from, you know, real life.
sources: Sony Xperia XZ1, Sony Xperia XZ1 Compact
Things that are NOT allowed: