Hi,
I've tried the above code here and it works just fine. I don't have a 16F877 so I tried it on a 18F25K20, the dutycylce of PWM-signal changes just as expected - no problem.

I looked at the datasheet for the 16F877 and the CCP1 pin isn't multiplexed with any other functions so it should work. Have you tried this with real hardware or are you still messing around with the simulator? My guess is that you're measuring on the wrong pin or that you have that simulator of yours set up wrong or that the PWM module isn't simulated properly.