I am trying to understand the behavior of gl_vertexID in vertex shaders. For that I am trying to render 2 squares using two glDrawArrays calls one after another. And want to apply red color to only one square using gl_VertexID in vertex as :

Code :
#version 300 es
precision highp float;
out vec4 color;
in vec4 tdk_Vertex;
void main(void)
if(gl_VertexID < 4)
    color = vec4(1.0f, 0.0f, 0.0f, 1.0f);
    color = vec4(1.0f, 1.0f, 1.0f, 1.0f);
gl_Position = tdk_Vertex;

Passing color to fragment shaders.

Square coordinates as :

Code :
static GLfloat vertices[] =
       { -0.75f, 0.25f, 0.0f, 1.0f,
         -0.75f, 0.5f,  0.0,  1.0f,
         -0.25f, 0.5f,  0.0f, 1.0f,
         -0.25f, 0.25f, 0.0f, 1.0f,
          0.25f, 0.25f, 0.0f, 1.0f,
          0.25f, 0.5f,  0.0f, 1.0f,
          0.75f, 0.5f, 0.0f,  1.0f,
          0.75f, 0.25f, 0.0f, 1.0f};

Making draw calls as :

Code :
for(int i=0; i<8; i+=4)
     glDrawArrays(GL_TRIANGLE_FAN, i, 4);

Using Nvidia card, and calling two glDrawArrays calls is displaying the expected result i.e rendering red color to one square and white to other.

Thus, want to know is this correct behaviour or gl_VertexID indices should generated during glDrawArrays call so that both squares have same red color?

I am using 2 glDrawArrays calls , so my understanding is that both squares should be red according to specification.
Want to test it for glsl 300 es.