How do those work? How would they know which passengers needs to go through customs at YYZ and which don't? I'm very curious as to how this would work.
Not sure about that particular flight, but "in the good old days" there were some direct flights where this was indeed the case, however the airline would fly a half empty plane on the domestic route and no new pax would board at the intermediate airport.
Nowadays this only happens where the airline has no traffic rights for the domestic leg. E.g. TS used to fly XXX-YVR-YEG and people just got off at YVR, and whoever stayed onboard would go through customs at YEG.