Beijing was never going to welcome the news that the US had passed a law backing pro-democracy protesters in Hong Kong. But its anger today at Donald Trump’s signing of a bill it condemns as “full of prejudice and arrogance” perhaps had extra bite. This was its third blow in a week. On Monday, leaders woke up to a pro-democracy landslide in Hong Kong’s local elections, and the publication of leaked documents exposing the workings of internment camps in Xinjiang, where at least a million Uighurs and other Muslims are believed to be detained.

China’s bullishness has already been challenged by the trade war and slowing economic growth, now at a 27-year low. Mr Trump has previously made it clear that he regards Hong Kong’s protesters as leverage, and has shown he does not want this law to hinder a trade deal that both sides need and appear to be close to agreeing. China is hoping he will not implement the law, which enables sanctions on individuals and the revocation of the region’s special trade status if annual reviews find that it has not retained sufficient autonomy.

The passage of the Hong Kong Human Rights and Democracy Act may prove to be most important in embodying the striking shift in US attitudes towards China. The rise of Mr Trump and his political opportunism has played a part; so has the “clash of civilisations” mindset of some of those around him. But the shift has taken place across the political spectrum and it is not primarily about what has changed in America, but what has changed in China: its ever-increasing authoritarianism under Xi Jinping.

Western engagement with China rested largely on a blithe and now utterly discredited assumption that economic liberalisation would bring political freedoms. The bilateral relationship is responding to the change in China’s relationship with its own people. The tightened grip has been seen most clearly on its periphery, in Xinjiang and Hong Kong, albeit by very different means and to very different degrees.

The erosion of Hong Kong’s autonomy has been clearer precisely because it still enjoys freedoms and rights denied to people on the mainland, who do not get to deliver a verdict on their leaders. Though the district council elections are usually low stakes affairs, they had effectively become a referendum on the city’s political future. It appears authorities may have believed that a “silent majority” would come out to reject the protests by voting for pro-Beijing candidates. The silent majority duly showed up – with turnout soaring in the biggest electoral exercise the city has seen – but overwhelmingly backed the other side. Pro-democracy candidates took 392 seats (to 60) and seized control of 17 out of 18 district councils. The message was clear. Hong Kong people embrace peaceful democratic means when they are available. And they are on the side of the protesters.

Extraordinary levels of control and surveillance make it far harder to determine what is happening in Xinjiang, despite dogged researchers and horrifying accounts of abuse and torture from former camp inmates and their families. Now documents obtained by the International Consortium of Investigative Journalists and shared with the Guardian and other media partners have laid bare their workings (the Chinese embassy in London said the documents were fabricated). Authorities initally denied the camps and now portray them as vocational training centres. The internal papers tell another story: “Never allow escapes.”

These two stories are connected by more than the wrath they have roused in Beijing. Despite the gulf between the cultures and experiences of the regions, people in Hong Kong increasingly cite the north-western region as a kind of warning, seeing Xinjiang as at the far end of a slope down which they fear they will slide unless they take a stand now.

In recent years, China’s economic might has silenced many critics and muted others. Though the new US law and renewed protests over the treatment of Muslim minorities in the wake of the leaked files suggest things may be evolving, many will decide it is too costly to care. After this week, however, they can no longer say they did not know.

Beijing was never going to welcome the news that the US had passed a law backing pro-democracy protesters in Hong Kong. But its anger today at Donald Trump’s signing of a bill it condemns as “full of prejudice and arrogance” perhaps had extra bite. This was its third blow in a week. On Monday, leaders woke up to a pro-democracy landslide in Hong Kong’s local elections, and the publication of leaked documents exposing the workings of internment camps in Xinjiang, where at least a million Uighurs and other Muslims are believed to be detained.

China’s bullishness has already been challenged by the trade war and slowing economic growth, now at a 27-year low. Mr Trump has previously made it clear that he regards Hong Kong’s protesters as leverage, and has shown he does not want this law to hinder a trade deal that both sides need and appear to be close to agreeing. China is hoping he will not implement the law, which enables sanctions on individuals and the revocation of the region’s special trade status if annual reviews find that it has not retained sufficient autonomy.

The passage of the Hong Kong Human Rights and Democracy Act may prove to be most important in embodying the striking shift in US attitudes towards China. The rise of Mr Trump and his political opportunism has played a part; so has the “clash of civilisations” mindset of some of those around him. But the shift has taken place across the political spectrum and it is not primarily about what has changed in America, but what has changed in China: its ever-increasing authoritarianism under Xi Jinping.

Western engagement with China rested largely on a blithe and now utterly discredited assumption that economic liberalisation would bring political freedoms. The bilateral relationship is responding to the change in China’s relationship with its own people. The tightened grip has been seen most clearly on its periphery, in Xinjiang and Hong Kong, albeit by very different means and to very different degrees.

The erosion of Hong Kong’s autonomy has been clearer precisely because it still enjoys freedoms and rights denied to people on the mainland, who do not get to deliver a verdict on their leaders. Though the district council elections are usually low stakes affairs, they had effectively become a referendum on the city’s political future. It appears authorities may have believed that a “silent majority” would come out to reject the protests by voting for pro-Beijing candidates. The silent majority duly showed up – with turnout soaring in the biggest electoral exercise the city has seen – but overwhelmingly backed the other side. Pro-democracy candidates took 392 seats (to 60) and seized control of 17 out of 18 district councils. The message was clear. Hong Kong people embrace peaceful democratic means when they are available. And they are on the side of the protesters.

Extraordinary levels of control and surveillance make it far harder to determine what is happening in Xinjiang, despite dogged researchers and horrifying accounts of abuse and torture from former camp inmates and their families. Now documents obtained by the International Consortium of Investigative Journalists and shared with the Guardian and other media partners have laid bare their workings (the Chinese embassy in London said the documents were fabricated). Authorities initally denied the camps and now portray them as vocational training centres. The internal papers tell another story: “Never allow escapes.”

These two stories are connected by more than the wrath they have roused in Beijing. Despite the gulf between the cultures and experiences of the regions, people in Hong Kong increasingly cite the north-western region as a kind of warning, seeing Xinjiang as at the far end of a slope down which they fear they will slide unless they take a stand now.

In recent years, China’s economic might has silenced many critics and muted others. Though the new US law and renewed protests over the treatment of Muslim minorities in the wake of the leaked files suggest things may be evolving, many will decide it is too costly to care. After this week, however, they can no longer say they did not know.