These are rain gutters.
They are designed to catch rain that runs off the upper surface of the aircraft fuselage and channel it away from the open aircraft door so that the water does not enter the cabin.
A jet-bridge may partially deflect rainwater in some cases, but the gutter helps mitigate water exposure for the aircraft interior and passengers. Even gutters cannot completely eliminate such exposure since their size is necessarily limited by aerodynamic constraints
"Rain Gutters" is the technical name, at least for Boeing aircraft, such as the B777 depicted in the photos in the question.
Here is a Boeing reference to such gutters on the 787:
It's for the passengers on a rainy day. If this strip would not be diverting the rainwater flowing from the upper fuselage, a curtain of water would soak the passengers upon entering or leaving the aircraft, and the cabin floor.